You are on page 1of 11

1. What is (void*)0? A. Representation of NULL pointer B. Representation of void pointer C. Error D.None of above Answer: Option A 2.

What will be the output of the program ? #include<stdio.h> int main() { int i=3, *j, k; j = &i; printf("%d\n", i**j*i+*j); return 0; } A.30 B. 27 C. 9 D. 3

Answer: Option A 3. What will be the output of the program If the integer is 4bytes long? #include<stdio.h> int main() { int ***r, **q, *p, i=8; p = &i; q = &p; r = &q; printf("%d, %d, %d\n", *p, **q, ***r); return 0; } A. 8, 8, 8 C. 4000, 4004, 4008 Answer: Option A 4. What will be the output of the program ?

B. 4000, 4002, 4004 D.4000, 4008, 4016

#include<stdio.h> int main() { void *vp; char ch=74, *cp="JACK"; int j=65; vp=&ch; printf("%c", *(char*)vp); vp=&j; printf("%c", *(int*)vp); vp=cp; printf("%s", (char*)vp+2); return 0; } A. JCK C. JAK Answer: Option D 5. What will be the output of the program ? #include<stdio.h> int main() { char str[] = "peace"; char *s = str; printf("%s\n", s++ +3); return 0; } A. Peace C. Ace Answer: Option D 6. What will be the output of the program ? #include<stdio.h> int main() { char *p; p="hello"; printf("%s\n", *&*&p); return 0; }


B. eace D.ce

A. Llo C. Ello Answer: Option B

B. hello D.h

7. Point out the compile time error in the program given below. #include<stdio.h> int main() { int *x; *x=100; return 0; } A. Error: invalid assignment for x B. Error: suspicious pointer conversion C. No error D.None of above Answer: Option C 8. What function should be used to free the memory allocated by calloc() ? A. dealloc(); C. free(); Answer: Option C 9. Assume integer is 2 bytes wide. How many bytes will be allocated for the following code? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int (*p)[MAXCOL]; p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p)); return 0; } A. 56 bytes B. 128 bytes C. 24 bytes D.12 bytes Answer: Option C B. malloc(variable_name, 0) D.memalloc(variable_name, 0)

10. What does the following declaration mean? int (*ptr)[10]; A. ptr is array of pointers to 10 integers B. ptr is a pointer to an array of 10 integers C. ptr is an array of 10 integers D.ptr is an pointer to array Answer: Option B 11. In C, if you pass an array as an argument to a function, what actually gets passed? A. Value of elements in array B. First element of the array C. Base address of the array D.Address of the last element of array Answer: Option C 12. What will be the output of the program ? #include<stdio.h> int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } A. 2, 1, 15 C. 3, 2, 15 Answer: Option C 13. The keyword used to transfer control from a function back to the calling function is A. Switch C. go back Answer: Option D 14. Point out the error in the program B. goto D.return

B. 1, 2, 5 D.2, 3, 20

f(int a, int b) { int a; a = 20; return a; } A. Missing parenthesis in return statement B. The function should be defined as int f(int a, int b) C. Redeclaration of a D.None of above Answer: Option C 15. If the two strings are identical, then strcmp() function returns A. -1 C. 0 Answer: Option C 16. How will you print \n on the screen? A. printf("\n"); C. printf('\n'); Answer: Option D 17. Which of the following function is more appropriate for reading in a multi-word string? A. printf(); C. gets(); Answer: Option C 18. What will be the output of the program ? #include<stdio.h> int main() { printf(5+"Good Morning\n"); return 0; } A. Good Morning C. M B. scanf(); D.puts(); B. echo "\\n"; D.printf("\\n"); B. 1 D.Yes

B. Good D.Morning

Answer: Option D 19. What will be the output of the program ? #include<stdio.h> int main() { char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"}; int i; char *t; t = names[3]; names[3] = names[4]; names[4] = t; for(i=0; i<=4; i++) printf("%s,", names[i]); return 0; } A. Suresh, Siva, Sona, Baiju, Ritu B. Suresh, Siva, Sona, Ritu, Baiju C. Suresh, Siva, Baiju, Sona, Ritu D.Suresh, Siva, Ritu, Sona, Baiju Answer: Option B 20. What will be the output of the program ? #include<stdio.h> int main() { int i; char a[] = "\0"; if(printf("%s", a)) printf("The string is empty\n"); else printf("The string is not empty\n"); return 0; } A. The string is empty C. No output Answer: Option B B. The string is not empty D.0

21. Which of the following is the correct order of evaluation for the below expression? z=x+y*z/4%2-1 A. * / % + - = C. / * % - + = Answer: Option A 22. Which of the following are unary operators in C? 1. ! 2. sizeof 3. ~ 4. && A. 1, 2 C. 2, 4 Answer: Option D 23. In which order do the following gets evaluated 1. Relational 2. Arithmetic 3. Logical 4. Assignment A. 2134 C. 4321 Answer: Option A 24. How would you round off a value from 1.66 to 2.0? A. ceil(1.66) C. roundup(1.66) Answer: Option A 25. By default a real number is treated as a A. Float C. long double Answer: Option B B. double D.far double B. floor(1.66) D.roundto(1.66) B. 1234 D.3214 B. 1, 3 D.1, 2, 3 B. = * / % + D.* % / - + =

26. Is the following statement a declaration or definition? extern int i; A. Declaration C. Function Answer: Option A 27. When we mention the prototype of a function? A. Defining C. Prototyping Answer: Option B 28. What will be the output of the program? #include<stdio.h> int main() { const int x=5; const int *ptrx; ptrx = &x; *ptrx = 10; printf("%d\n", x); return 0; } A. 5 C. Error Answer: Option C 29. What does fp point to in the program ? #include<stdio.h> int main() { FILE *fp; fp=fopen("trial", "r"); return 0; } A. The first character in the file B. 10 D.Garbage value B. Declaring D.Calling B. Definition D.Error

B. A structure which contains a char pointer which points to the first character of a file. C. The name of the file. D.The last character in the file. Answer: Option B 30. To print out a and b given below, which of the following printf() statement will you use? #include<stdio.h> float a=3.14; double b=3.14; A. printf("%f %lf", a, b); B. printf("%Lf %f", a, b); C. printf("%Lf %Lf", a, b); D.printf("%f %Lf", a, b); Answer: Option A 31. Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+"); A. Reading C. Appending Answer: Option D 32. Which files will get closed through the fclose() in the following program? #include<stdio.h> int main() { FILE *fs, *ft, *fp; fp = fopen("A.C", "r"); fs = fopen("B.C", "r"); ft = fopen("C.C", "r"); fclose(fp, fs, ft); return 0; } A. "A.C" "B.C" "C.C" B. "B.C" "C.C" B. Writing D.Read and Write

C. "A.C" Answer: Option D

D.Error in fclose()

33. To scan a and b given below, which of the following scanf() statement will you use? #include<stdio.h> float a; double b; A. scanf("%f %f", &a, &b); C. scanf("%f %Lf", &a, &b); Answer: Option D 34. How many times the while loop will get executed if a short int is 2 byte wide? #include<stdio.h> int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; } A. Infinite times C. 256 times Answer: Option B 35. Which of the following cannot be checked in a switch-case statement? A. Character C. Float Answer: Option C B. Integer D.enum B. 255 times D.254 times B. scanf("%Lf %Lf", &a, &b); D.scanf("%f %lf", &a, &b);