100 Multiple Choice Questions In C Programming – Part 5
This collection of 100 Multiple Choice Questions and Answers (MCQs) In C Programming : Quizzes & Practice Tests with Answer focuses on “C Programming”.
1. How many times do we get through the following loop?
int c = 10; while (( c <11 ) { printf("Hello World\n"); }
A 0
B 1
C 9
D it is an infinite loop
2. Which data type is most appropriate for storing the value 57000 in a 32-bit system?
A signed short
B unsigned short
C long
D int
[st_adsense]
3. Which of the following is a user-defined data type?
A typedef int Boolean;
B typedef enum {Monday, Tuesday, Wednesday, Thursday, Friday} Days;
C struct {char address[25], int age};
D All the answers are true
4. How many times do we get through the following loop?
for ( counter = 2; counter < 9; counter += 2 )
A 4
B 5
C 7
D 8
5. What is the size of int type?
A 4 Bytes
B 8 Bytes
C Depends on system and compiler
D Cannot be determined
6. What is the output of the following C program?
#include <stdio.h> int main() { signed char c; c= 235; printf("%d\n", c); return 0; }
A 235
B -235
C Depends on compiler
D None of the above
[st_adsense]
7. What happens after a return?
A The function stops and returns the indicated result
B The function continues and returns the indicated result
C The function continues and returns no result
D None of the above
8. What is the output of the following C program?
#include <stdio.h> int main() { char c; int i = 0; FILE *file; // write to the text file file = fopen("test.txt", "w+"); fprintf(file, "%c", 'x'); fprintf(file, "%c", -1); fprintf(file, "%c", 'y'); fclose(file); // read from the text file file = fopen("test.txt", "r"); while ((c = fgetc(file)) != -1) printf("%c", c); return 0; }
A Display x
B Infinite loop
C Depends on what fgetc returns
D Depends on compiler
9. What does “short int” mean in C programming?
A basic data type
B qualifier
C short is the qualifier and int is the basic data type
D All the answers are true
[st_adsense]
10. What is the output of the following C program?
#include <stdio.h> int main() { float a = 0.1; if (a == 0.1) printf("equal\n"); else printf("not equal\n"); }
A equal
B not equal
C the output depends on the compiler
D None of the above
11. What is the output of the following C program?
#include <stdio.h> int main() { float a = 0.1; if (a == 0.1f) printf("equal\n"); else printf("not equal\n"); }
A equal
B not equal
C the output depends on the compiler
D None of the above
[st_adsense]