

MCQOPTIONS
Saved Bookmarks
This section includes 52 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ double d = 2.25; printf ("%e", d); printf ("%f", d); printf ("%g".d); printf ("%lf n", d); return 0 ;} |
A. | 2.2 2.50 2.50 2.5 |
B. | 2.2e 2.25f 2.00 2.25 |
C. | 2.250000e + 000 2.250000 2.25 2.250000 |
D. | Error |
Answer» D. Error | |
2. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ float f = 43.20; printf ("%e", f); printf ("%f", f); printf ("%g n" , f); return 0 ;} |
A. | 4.320000e + 001 43.200001 43.2 |
B. | 4.3 43.22 43.21 |
C. | 4.3e 43.20f 43.00 |
D. | Error |
Answer» B. 4.3 43.22 43.21 | |
3. |
Which of the following statements are correct about the program given below?#include <stdio.h>int main () { float k = 0.7; if (k < 0.7) printf ("C n"); else printf ("C++ n"); return 0 ;} |
A. | The program will output C |
B. | The program will output C++ |
C. | Compiler will report an error saying a float cannot be compared with a double. |
D. | Output will be C for 16-bit compilers and C++ for 32-bit compilers |
Answer» B. The program will output C++ | |
4. |
Which of the following is the correct output for the program given below? #include <stdio.h>int main ( ){ float n = 2.39; printf("%f %f n", ceil (n), floor (n)) ; return 0 ;} |
A. | 3.000000 2.000000 |
B. | 2.500000 2.500000 |
C. | 2.550000 3.000000 |
D. | 2.000000 3.000000 |
Answer» B. 2.500000 2.500000 | |
5. |
Which of the following is the correct output for the program given below?#include <stdio.h>#include <math.h>int main ( ){ printf ( "%f n" ,sqrt (49.0)); return 0 ;} |
A. | 7.0 |
B. | 7 |
C. | 7.000000 |
D. | Error : Prototype of sqrt ( ) not found |
Answer» D. Error : Prototype of sqrt ( ) not found | |
6. |
Which of the following is the correct output for the program given below?#include<stdio.h>int main ( ){ float *p; printf ( "%d n " , sizeof ( p ) ); return 0 ;} |
A. | 2 in 16-bit compiler like TC/TC++, 4 in 32-bit compiler like Visual studio or gcc |
B. | 4 in 16-bit compiler like TC/TC++, 2 in 32-bit compiler like Visual Studio or gcc |
C. | 4 in 16-bit compiler like TC/TC++, 4 in 32-bit compiler like Visual Studio or gcc |
D. | 2 in 16-bit compiler like TC/TC++, 2 in 32-bit compiler like Visual studio or gcc |
Answer» B. 4 in 16-bit compiler like TC/TC++, 2 in 32-bit compiler like Visual Studio or gcc | |
7. |
Which error are you likely to get when you run the following program in TC/TC++?#include <stdio.h>int main ( ){ struct emp { char name[20]; float sal; }; struct emp e[10]; int i ; for (i = 0; i <= 9; i++) { printf ("Enter name and salary : "); scanf ("%s %f" , e[ i ].name, &e[ i ].sal); } return 0 ;} |
A. | Suspicious pointer conversion |
B. | Floating point formats not linked |
C. | Cannot use scanf ( ) for structures |
D. | Strings cannot be nested inside structures |
Answer» C. Cannot use scanf ( ) for structures | |
8. |
If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the following program?#include <stdio.h>int main ( ){ float a =5.375 ; char *p ; int i ; p = (char *) &a ; for (i = 0 ; i <= 3 ; i++) printf("%02 X n" , (unsigned char) p[ i ]); return 0 ;} |
A. | 40 AC 00 00 |
B. | 04 CA 00 00 |
C. | 00 00 AC 40 |
D. | 00 00 CA 04 |
Answer» D. 00 00 CA 04 | |
9. |
What will be the output of the following C code?#include <stdio.h> void main() { float num = 0.3; if (num == 0.3) printf("Interview Mania"); else printf("Advanced C Classes"); } |
A. | Advanced C Classes |
B. | Interview Mania |
C. | Compilation Error |
D. | Runtime Error |
E. | None of these |
Answer» B. Interview Mania | |
10. |
What will be the output of the following C code? #include <stdio.h> int main() { float f = 'I'; printf("%f", f); return 0; } |
A. | Compilation Error |
B. | I |
C. | 73.000000 |
D. | Runtime Error |
E. | None of these |
Answer» D. Runtime Error | |
11. |
What will be the output of the following C code? #include <stdio.h> int main() { unsigned int n = 25; signed char ch = -25; if (n > ch) { printf("Yes n"); } else if (n < ch) { printf("No n"); } } |
A. | Yes |
B. | No |
C. | Depends on the compiler |
D. | Depends on the compiler |
E. | None of these |
Answer» C. Depends on the compiler | |
12. |
What will be the output of the following C code?#include <stdio.h> void main() { int n = 98; char m = n; printf("%c n", m); } |
A. | 98 |
B. | Compilation error |
C. | b |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
13. |
What will be the output of the following C code?#include <stdio.h> void main() { double n = 23458965.12124; int m = n; printf("%d", m); printf(" %lf", m); } |
A. | 23458965, 0.000000 |
B. | 0.000000, 23458965 |
C. | Compilation Error |
D. | Runtime Error |
E. | None of these |
Answer» B. 0.000000, 23458965 | |
14. |
What will be the output of the following C code? (Initial values: p= 10, q = 12)#include <stdio.h> void main() { float p; int q; printf("Enter two numbers: ", p); scanf("%f %f", &p, &q); printf("%f, %d", p, q); } |
A. | 10.000000, 12 |
B. | 12, 10.000000 |
C. | 12, Garbage value |
D. | Garbage value, 10.000000 |
E. | 10.000000, Garbage value |
Answer» F. | |
15. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 25; char ch = -25; if (n < ch) { printf("Yes n"); } else { printf("No n"); } } |
A. | 25 |
B. | Yes |
C. | No |
D. | Depends on the compiler |
E. | Depends on the standard |
Answer» D. Depends on the compiler | |
16. |
What will be the output of the following C code on a 32-bit machine?#include <stdio.h> int main() { int n = 210; double m = 65; int *ptr1 = &n; double *ptr2 = &m; printf("n and m are %d and %d", sizeof(ptr1), sizeof(ptr2)); return 0; } |
A. | 210 |
B. | 65 |
C. | Depends on compiler |
D. | Compilation Error |
E. | None of these |
Answer» D. Compilation Error | |
17. |
In the following C code, the union size is decided by?union temp { char ch; int n; float f; }; |
A. | float |
B. | int |
C. | both float and int |
D. | char |
E. | None of these |
Answer» D. char | |
18. |
What will be the data type of the result of the following operation?(float)p * (int)q / (long)r * (double)s |
A. | double |
B. | float |
C. | long |
D. | int |
E. | None of these |
Answer» B. float | |
19. |
What will be the output of the following C code considering the size of short int is 2, char is 1 and int is 4 bytes?#include <stdio.h> int main() { short int k = 23; char ch = 99; printf("%d, %d, %d n", sizeof(k), sizeof(ch), sizeof(ch + k)); return 0; } |
A. | 23 |
B. | 99 |
C. | 2, 1, 4 |
D. | 4, 1, 2 |
E. | None of these |
Answer» D. 4, 1, 2 | |
20. |
What will be the output of the following C code on a 64 bit machine?#include <stdio.h> union Stir { int num; char ch; }; int main() { union Stir str; printf("%d", sizeof(str)); return 0; } |
A. | str |
B. | Compilation Error |
C. | 4 |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
21. |
What will be the output of the following C code?#include printf("%.0f", 4.89); |
A. | 4.890000 |
B. | 4.89 |
C. | 4 |
D. | 5 |
E. | None of these |
Answer» E. None of these | |
22. |
What will be the output of the following C code?#include <stdio.h> void main() { float num = 0.2; printf("%d, ", num); printf("%f", num); } |
A. | Garbage value, 0.200000 |
B. | 0.200000, Garbage value |
C. | Compilation Error |
D. | Runtime Error |
E. | None of these |
Answer» B. 0.200000, Garbage value | |
23. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ float floatvalue = 8.25; printf ("%d n " , (int) floatvalue); return 0;} |
A. | 0 |
B. | 0.0 |
C. | 8.0 |
D. | 8 |
Answer» E. | |
24. |
Which of the following is the correct datatype for the variable n in the statement given below?n = 35.29 ; |
A. | float |
B. | double |
C. | long double |
D. | Depends upon the memory model that you are using |
Answer» B. double | |
25. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ printf ("%d %d %d n" , sizeof(2.19f), sizeof(2.19), sizeof (2.19l)); return 0 ;} |
A. | 4 4 4 |
B. | 4 8 8 |
C. | 4 8 10 |
D. | 4 8 12 |
Answer» C. 4 8 10 | |
26. |
What will be the output of the following C code?#include <stdio.h> int main() { float num = 0.2; if (num == 0.2f) { printf("Equal n"); } else { printf("Not Equal n"); } } |
A. | Equal |
B. | Not Equal |
C. | output depends on compiler |
D. | Compilation Error |
E. | None of these |
Answer» B. Not Equal | |
27. |
What will be the output of the following C code?#include <stdio.h> int main() { float fl = 15.621212121212; printf("%f", fl); } |
A. | 15.621212121212 |
B. | Compilation Error |
C. | Garbage value |
D. | 15.621212 |
E. | None of these |
Answer» E. None of these | |
28. |
What will be the output of the following C code?#include <stdio.h> int main() { float num1 = 0.2; if (num1 == 0.2) { printf("Equal n"); } else { printf("Not Equal n"); } } |
A. | Compilation Error |
B. | 0.2 |
C. | Equal |
D. | Not Equal |
E. | None of these |
Answer» E. None of these | |
29. |
Which data type is suitable for storing a number like?25.00002500025 |
A. | double |
B. | int |
C. | both int and double |
D. | float |
E. | None of these |
Answer» B. int | |
30. |
What is the output of the following C code? #include <stdio.h> int main() { signed char ch; ch = 129; printf("%d n", ch); return 0; } |
A. | 129 |
B. | -129 |
C. | 127 |
D. | -127 |
E. | None of these |
Answer» E. None of these | |
31. |
What will be the output of the following C code? #include <stdio.h> int main() { char ch; int k = 0; FILE *file; file = fopen("Example.txt", "w+"); fprintf(file, "%c", 'I'); fprintf(file, "%c", -1); fprintf(file, "%c", 'L'); fclose(file); file = fopen("Example.txt", "r"); while ((ch = fgetc(file)) != -1) printf("%c", ch); return 0; } |
A. | I |
B. | -1 |
C. | L |
D. | Compilation Error |
E. | None of these |
Answer» B. -1 | |
32. |
Which of the following is the correct output for the program given below? #include <stdio.h>int main ( ) { float n = 5.375 ; printf("%f %e %E n" , n, n, n) ; return 0 ;} |
A. | 5.375 5.375 5.375 |
B. | 5.375000 5.375000 5.375000 |
C. | 5.375000 5.375000e+000 5.375000E+000 |
D. | 5.375000 5.375000E+000 5.375000e+000 |
Answer» D. 5.375000 5.375000E+000 5.375000e+000 | |
33. |
What is the output of this C code?#include <stdio.h>int main(){ char chr; chr = 128; printf("%d n", chr); return 0;} |
A. | 128 |
B. | -128 |
C. | Depends on the compiler |
D. | None of the mentioned |
Answer» C. Depends on the compiler | |
34. |
Predict the data type of the following mathematical operation?2 * 9 + 3 / 2 . 0 |
A. | long |
B. | double |
C. | float |
D. | int |
E. | None of these |
Answer» C. float | |
35. |
Which error are you likely to get when you run the following program in TC/TC++? |
A. | Suspicious pointer conversion |
B. | Floating point formats not linked |
C. | Cannot use scanf ( ) for structures |
D. | Strings cannot be nested inside structures |
Answer» C. Cannot use scanf ( ) for structures | |
36. |
We want to round off x, a float, to an int value. The correct way to do so will be |
A. | y = ( int ) ( x + 0.5); |
B. | y = int ( x +0.5 ); |
C. | y = ( int ) x + 0.5; |
D. | y = ( int ) ( ( int ) x + 0.5 ) |
Answer» B. y = int ( x +0.5 ); | |
37. |
If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the following program? |
A. | 40 AC 00 00 |
B. | 04 CA 00 00 |
C. | 00 00 AC 40 |
D. | 00 00 CA 04 |
Answer» D. 00 00 CA 04 | |
38. |
Which of the following is valid range of long double ? |
A. | 3.4E-4932 to 1.1E+4932 |
B. | 3.4E-4932 to 3.4E+4932 |
C. | 1.1E-4932 to 1.1E+4932 |
D. | 1.7E - 308 to 1.7E + 308 |
Answer» E. | |
39. |
What is the range of a signed char variable in C? |
A. | 0 to 255 |
B. | -128 to 127 |
C. | 0 to 127 |
D. | -128 to 255 |
Answer» C. 0 to 127 | |
40. |
Which of the following is the correct datatype for the variable n in the statement given below? |
A. | float |
B. | double |
C. | long double |
D. | Depends upon the memory model that you are using |
Answer» B. double | |
41. |
Predict the data type of the following mathematical operation? |
A. | long |
B. | double |
C. | float |
D. | int |
E. | None of these |
Answer» C. float | |
42. |
Which data type is suitable for storing a number like? |
A. | double |
B. | int |
C. | both int and double |
D. | float |
E. | None of these |
Answer» B. int | |
43. |
%f access specifier is used for ________. |
A. | Integral types |
B. | Floating type |
C. | Strings |
D. | All of above |
E. | None of these |
Answer» C. Strings | |
44. |
In the following C code, the union size is decided by? |
A. | float |
B. | int |
C. | both float and int |
D. | char |
E. | None of these |
Answer» D. char | |
45. |
What will be the data type of the result of the following operation? |
A. | double |
B. | float |
C. | long |
D. | int |
E. | None of these |
Answer» B. float | |
46. |
What will be the output of the following C code considering the size of short int is 2, char is 1 and int is 4 bytes? |
A. | 23 |
B. | 99 |
C. | 2, 1, 4 |
D. | 4, 1, 2 |
E. | None of these |
Answer» D. 4, 1, 2 | |
47. |
function tolower(c) defined in library works for ___________. |
A. | Unicode character set |
B. | Ascii and utf-8 but not EBCDIC character set |
C. | Ascii character set |
D. | Any character set |
E. | None of these |
Answer» E. None of these | |
48. |
The format identifier %i is also used for _____ data type. |
A. | double |
B. | char |
C. | int |
D. | float |
E. | None of these |
Answer» D. float | |
49. |
What will be the output of the following C code? (Initial values: p= 10, q = 12) |
A. | 10.000000, 12 |
B. | 12, 10.000000 |
C. | 12, Garbage value |
D. | Garbage value, 10.000000 |
E. | 10.000000, Garbage value |
Answer» F. | |
50. |
What will be the output of the following C code on a 64 bit machine? |
A. | str |
B. | Compilation Error |
C. | 4 |
D. | All of above |
E. | None of these |
Answer» D. All of above | |