MCQOPTIONS
Saved Bookmarks
This section includes 278 Mcqs, each offering curated multiple-choice questions to sharpen your C Interview knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
C Language developed at _________? |
| A. | AT & T's Bell Laboratories of USA in 1972 |
| B. | AT & T's Bell Laboratories of USA in 1970 |
| C. | Sun Microsystems in 1973 |
| D. | Cambridge University in 1972 |
| Answer» B. AT & T's Bell Laboratories of USA in 1970 | |
| 2. |
For 16-bit compiler allowable range for integer constants is ________? |
| A. | -3.4e38 to 3.4e38 |
| B. | -32767 to 32768 |
| C. | -32668 to 32667 |
| D. | -32768 to 32767 |
| Answer» E. | |
| 3. |
C programs are converted into machine language with the help of |
| A. | An Editor |
| B. | A compiler |
| C. | An operating system |
| D. | None of these. |
| Answer» C. An operating system | |
| 4. |
C was primarily developed as |
| A. | System programming language |
| B. | General purpose language |
| C. | Data processing language |
| D. | None of the above. |
| Answer» B. General purpose language | |
| 5. |
What will be printed after execution of the following program code? main() { printf("\\nab"); printf("\\bsi"); printf("\\rha"); } |
| A. | absiha |
| B. | asiha |
| C. | haasi |
| D. | hai |
| Answer» E. | |
| 6. |
What number would be shown on the screen after the following statements of C are executed? char ch; int i; ch = 'G'; i = ch-'A'; printf("%d", i); |
| A. | 5 |
| B. | 6 |
| C. | 7 |
| D. | 8 |
| Answer» C. 7 | |
| 7. |
Find the output of the following program. void main() { int i=01289; printf("%d", i); } |
| A. | 0289 |
| B. | 1289 |
| C. | 713 |
| D. | Syntax error |
| Answer» E. | |
| 8. |
Find the output of the following program. void main() { int i=065, j=65; printf("%d %d", i, j); } |
| A. | 53 65 |
| B. | 65 65 |
| C. | 065 65 |
| D. | 053 65 |
| Answer» B. 65 65 | |
| 9. |
What is the output of given program if user enter value 99? #include void main() { int i; printf("Enter a number:"); scanf("%d", &i); // 99 is given as input. if(i%5 == 0){ printf("nNumber entered is divisible by 5"); } } |
| A. | Enter a number:99 |
| B. | Enter a number:99 Number is divisible by 5 |
| C. | compiler error |
| D. | Run time error |
| Answer» B. Enter a number:99 Number is divisible by 5 | |
| 10. |
What is the output of given program if user enter "xyz" ? #includevoid main() { float age, AgeInSeconds; printf("Enter your age:"); scanf("%f", &age); AgeInSeconds = 365 * 24 * 60 * 60 * age; printf("You have lived for %f seconds", AgeInSeconds);} |
| A. | Enter your age: xyz You have lived for 0 seconds |
| B. | Enter your age: xyz You have lived for 0.00000 seconds |
| C. | Enter your age: xyz "after that program will stop" |
| D. | Run time error |
| Answer» C. Enter your age: xyz "after that program will stop" | |
| 11. |
Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i |
| A. | The function calculates the value of 1 raised to power num. |
| B. | The function calculates the square root of an integer |
| C. | The function calculates the factorial value of an integer |
| D. | None of above |
| Answer» D. None of above | |
| 12. |
There is a error in the below program. Which statement will you add to remove it?#includeint main() { int a; a = f(10, 3.14); printf("%d\n", a); return 0; } float f(int aa, float bb) { return ((float)aa + bb); } |
| A. | Add prototype: float f(aa, bb) |
| B. | Add prototype: float f(int, float) |
| C. | Add prototype: float f(float, int) |
| D. | Add prototype: float f(bb, aa) |
| Answer» C. Add prototype: float f(float, int) | |
| 13. |
Which of the following statements are correct about the program?#includeint main() { printf("%p\n", main()); return 0; } |
| A. | It prints garbage values infinitely |
| B. | Runs infinitely without printing anything |
| C. | Error: main() cannot be called inside printf() |
| D. | No Error and print nothing |
| Answer» C. Error: main() cannot be called inside printf() | |
| 14. |
Point out the error in the program#includeint main() { int a=10; void f(); a = f(); printf("%d\n", a); return 0; } void f() { printf("Hi"); } |
| A. | Error: Not allowed assignment |
| B. | Error: Doesn't print anything |
| C. | No error |
| D. | None of above |
| Answer» B. Error: Doesn't print anything | |
| 15. |
Point out the error in the program#includeint f(int a) { a > 20? return(10): return(20); }int main() { int f(int); int b; b = f(20); printf("%d\n", b); return 0; } |
| A. | Error: Prototype declaration |
| B. | No error |
| C. | Error: return statement cannot be used with conditional operators |
| D. | None of above |
| Answer» D. None of above | |
| 16. |
Point out the error in the program 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» D. None of above | |
| 17. |
What will be the output of the program?#include#includeint main() { int i=0; i++; if(i |
| A. | Prints "Study2Online" 5 times |
| B. | Function main() doesn't calls itself |
| C. | Infinite loop |
| D. | Prints "Study2Online" |
| Answer» E. | |
| 18. |
What will be the output of the program?#includeint fun(int);int main() { float k=3; fun(k=fun(fun(k))); printf("%f\n", k); return 0; }int fun(int i) { i++; return i; } |
| A. | 5.000000 |
| B. | 3.000000 |
| C. | Garbage value |
| D. | 4.000000 |
| Answer» B. 3.000000 | |
| 19. |
What will be the output of the program?#includeint fun(int i) { i++; return i; }int main() { int fun(int); int i=3; fun(i=fun(fun(i))); printf("%d\n", i); return 0; } |
| A. | 5 |
| B. | 4 |
| C. | Error |
| D. | Garbage value |
| Answer» B. 4 | |
| 20. |
What will be the output of the program?#includeint fun(int(*)());int main() { fun(main); printf("Hi\n"); return 0; }int fun(int (*p)()) { printf("Hello "); return 0; } |
| A. | Infinite loop |
| B. | Hi |
| C. | Hello Hi |
| D. | Error |
| Answer» D. Error | |
| 21. |
If int is 2 bytes wide.What will be the output of the program?#include void fun(char**);int main() { char *argv[] = {"ab", "cd", "ef", "gh"}; fun(argv); return 0; }void fun(char **p) { char *t; t = (p+= sizeof(int))[-1]; printf("%s\n", t); } |
| A. | ab |
| B. | cd |
| C. | ef |
| D. | gh |
| Answer» C. ef | |
| 22. |
What will be the output of the program?#includeint check(int);int main() { int i=45, c; c = check(i); printf("%d\n", c); return 0; }int check(int ch) { if(ch >= 45) return 100; else return 10; } |
| A. | 100 |
| B. | 10 |
| C. | 1 |
| D. | 0 |
| Answer» B. 10 | |
| 23. |
What will be the output of the program?#includeint addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); }int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d, %d\n", k, l); return 0; } |
| A. | 12, 12 |
| B. | 7, 7 |
| C. | 7, 12 |
| D. | 12, 7 |
| Answer» B. 7, 7 | |
| 24. |
What will be the output of the program?#includeint func1(int);int main() { int k=35; k = func1(k=func1(k=func1(k))); printf("k=%d\n", k); return 0; } int func1(int k) { k++; return k; } |
| A. | k=35 |
| B. | k=36 |
| C. | k=37 |
| D. | k=38 |
| Answer» E. | |
| 25. |
What will be the output of the program?#includeint i;int fun1(int);int fun2(int);int main() { extern int j; int i=3; fun1(i); printf("%d,", i); fun2(i); printf("%d", i); return 0; }int fun1(int j) { printf("%d,", ++j); return 0; } int fun2(int i) { printf("%d,", ++i); return 0; } int j=1; |
| A. | 3, 4, 4, 3 |
| B. | 4, 3, 4, 3 |
| C. | 3, 3, 4, 4 |
| D. | 3, 4, 3, 4 |
| Answer» C. 3, 3, 4, 4 | |
| 26. |
What will be the output of the program?#includeint addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); }int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d %d\n", k, l); return 0; } |
| A. | 12 12 |
| B. | No error, No output |
| C. | Error: Compile error |
| D. | None of above |
| Answer» B. No error, No output | |
| 27. |
What will be the output of the program?#includeint main() { int i=1; if(!i) printf("Study2Online,"); else { i=0; printf("C-Program"); main(); } return 0; } |
| A. | prints "Study2Online, C-Program" infinitely |
| B. | prints "C-Program" infinetly |
| C. | prints "C-Program, Study2Online" infinitely |
| D. | Error: main() should not inside else statement |
| Answer» C. prints "C-Program, Study2Online" infinitely | |
| 28. |
What will be the output of the program?#includeint fun(int, int); typedef int (*pf) (int, int); int proc(pf, int, int);int main() { printf("%d\n", proc(fun, 6, 6)); return 0; } int fun(int a, int b) { return (a==b); }int proc(pf p, int a, int b) { return ((*p)(a, b)); } |
| A. | 6 |
| B. | 1 |
| C. | 0 |
| D. | -1 |
| Answer» C. 0 | |
| 29. |
What will be the output of the program?#includeint check (int, int);int main() { int c; c = check(10, 20); printf("c=%d\n", c); return 0; } int check(int i, int j) { int *p, *q; p=&i; q=&j; i>=45 ? return(*p): return(*q); } |
| A. | Print 10 |
| B. | Print 20 |
| C. | Print 1 |
| D. | Compile error |
| Answer» E. | |
| 30. |
What will be the output of the program?#includeint main() { int fun(int); int i = fun(10); printf("%d\n", --i); return 0; }int fun(int i) { return (i++); } |
| A. | 9 |
| B. | 10 |
| C. | 11 |
| D. | 8 |
| Answer» B. 10 | |
| 31. |
What will be the output of the program?#includeint main() { void fun(char*); char a[100]; a[0] = 'A'; a[1] = 'B'; a[2] = 'C'; a[3] = 'D'; fun(&a[0]); return 0; } void fun(char *a) { a++; printf("%c", *a); a++; printf("%c", *a); } |
| A. | AB |
| B. | BC |
| C. | CD |
| D. | No output |
| Answer» C. CD | |
| 32. |
What will be the output of the program?#includeint sumdig(int);int main(){ int a, b; a = sumdig(123); b = sumdig(123); printf("%d, %d\n", a, b); return 0; }int sumdig(int n) { int s, d; if(n!=0) { d = n%10; n = n/10; s = d+sumdig(n); } else return 0; return s; } |
| A. | 4, 4 |
| B. | 3, 3 |
| C. | 6, 6 |
| D. | 12, 12 |
| Answer» D. 12, 12 | |
| 33. |
What will be the output of the program?#includevoid fun(int);typedef int (*pf) (int, int);int proc(pf, int, int);int main() { int a=3; fun(a); return 0; }void fun(int n) { if(n > 0) { fun(--n); printf("%d,", n); fun(--n); } } |
| A. | 0, 2, 1, 0, |
| B. | 1, 1, 2, 0, |
| C. | 0, 1, 0, 2, |
| D. | 0, 1, 2, 0, |
| Answer» E. | |
| 34. |
What will be the output of the program?#includeint reverse(int);int main(){ int no=5; reverse(no); return 0; }int reverse(int no) { if(no == 0) return 0; else printf("%d,", no); reverse (no--); } |
| A. | Print 5, 4, 3, 2, 1 |
| B. | Print 1, 2, 3, 4, 5 |
| C. | Print 5, 4, 3, 2, 1, 0 |
| D. | Infinite loop |
| Answer» E. | |
| 35. |
What will be the output of the program? #includeint i;int fun();int main() { while(i) { fun(); main(); } printf("Hello\n"); return 0; } int fun() { printf("Hi"); } |
| A. | Hello |
| B. | Hi Hello |
| C. | No output |
| D. | Infinite loop |
| Answer» B. Hi Hello | |
| 36. |
What will be the output of the program? #includevoid fun(int*, int*);int main() { int i=5, j=2; fun(&i, &j); printf("%d, %d", i, j); return 0; } void fun(int *i, int *j) { *i = *i**i; *j = *j**j; } |
| A. | 5, 2 |
| B. | 10, 4 |
| C. | 2, 5 |
| D. | 25, 4 |
| Answer» E. | |
| 37. |
What will be the output of the program in 16 bit platform (Turbo C under DOS)?#includeint main() { int fun(); int i; i = fun(); printf("%d\n", i); return 0; } int fun() { _AX = 1990; } |
| A. | Garbage value |
| B. | 0 (Zero) |
| C. | 1990 |
| D. | No output |
| Answer» D. No output | |
| 38. |
How many times the program will print "Study 2 Online" ? #include int main() { printf("Study 2 Online"); main(); return 0; } |
| A. | Infinite times |
| B. | 32767 times |
| C. | 65535 times |
| D. | Till stack overflows |
| Answer» E. | |
| 39. |
In which order do the following gets evaluated Relational Arithmetic Logical Assignment |
| A. | 2134 |
| B. | 1234 |
| C. | 4321 |
| D. | 3214 |
| Answer» B. 1234 | |
| 40. |
Which of the following are unary operators in C? ! sizeof ~ && |
| A. | 1, 2 |
| B. | 1, 3 |
| C. | 2, 4 |
| D. | 1, 2, 3 |
| Answer» E. | |
| 41. |
How many times "Study 2 Online" is get printed?#includeint main(){int x; for(x=-1; x |
| A. | Infinite times |
| B. | 11 times |
| C. | 0 times |
| D. | 10 times |
| Answer» D. 10 times | |
| 42. |
Can you combine the following two statements into one? char *p; p = (char*) malloc(100); |
| A. | char p = *malloc(100); |
| B. | char *p = (char) malloc(100); |
| C. | char *p = (char*)malloc(100); |
| D. | char *p = (char *)(malloc*)(100); |
| Answer» D. char *p = (char *)(malloc*)(100); | |
| 43. |
Is there any difference between following declarations? extern int fun(); int fun(); |
| A. | Both are identical |
| B. | No difference, except extern int fun(); is probably in another file |
| C. | int fun(); is overrided with extern int fun(); |
| D. | None of these |
| Answer» C. int fun(); is overrided with extern int fun(); | |
| 44. |
Which of the following is the correct order if calling functions in the below code?a = f1(23, 14) * f2(12/4) + f3(); |
| A. | f1, f2, f3 |
| B. | f3, f2, f1 |
| C. | Order may vary from compiler to compiler |
| D. | None of above |
| Answer» D. None of above | |
| 45. |
Which of the datatypes have size that is variable? |
| A. | int |
| B. | struct |
| C. | float |
| D. | double |
| Answer» C. float | |
| 46. |
Which is correct with respect to size of the datatypes? |
| A. | char > int > float |
| B. | int > char > float |
| C. | char < int < double |
| D. | double > char > int |
| Answer» D. double > char > int | |
| 47. |
What is short int in C programming? |
| A. | Basic datatype of C |
| B. | Qualifier |
| C. | short is the qualifier and int is the basic datatype |
| D. | All of the mentioned |
| Answer» D. All of the mentioned | |
| 48. |
Which of the following cannot be a variable name in C? |
| A. | volatile |
| B. | true |
| C. | friend |
| D. | export |
| Answer» B. true | |
| 49. |
What is the problem in following variable declaration? float 3Bedroom-Hall-Kitchen?; |
| A. | The variable name begins with an integer |
| B. | The special character ‘-‘ |
| C. | The special character ‘?’ |
| D. | All of the mentioned |
| Answer» E. | |
| 50. |
Which is valid C expression? |
| A. | int my_num = 100,000; |
| B. | int my_num = 100000; |
| C. | int my num = 1000; |
| D. | int $my_num = 10000; |
| Answer» C. int my num = 1000; | |