Data Types in C MCQS

@T-Bone

This is the c programming questions and answers section on " Data Types " for various interview, competitive examination and entrance test. Solved examples with detailed answer description, explanation are given and it would be easy to understand.

This is the c programming questions and answers section on " Data Types " for various interview, competitive examination and entrance test. Solved examples with detailed answer description, explanation are given and it would be easy to understand.

Questions

1. Comment on the output of this C code? int main() { int a[5] = {1, 2, 3, 4, 5}; int I; for (i = 0; i < 5; i++) if ((char)a[i] == '5') printf("%d\n", a[I]); else printf("FAIL\n"); }

Mark the correct option

2. The format identifier '%i' is also used for _____ data type?

Mark the correct option

3. Which data type is most suitable for storing a number 65000 in a 32-bit system?

Mark the correct option

4. Which of the following is a User-defined data type?

Mark the correct option

5. What is the size of an int data type?

Mark the correct option

6. What is the output of this C code? int main() { char chr; chr = 128; printf("%d\n", chr); return 0; }

Mark the correct option

7. Comment on the output of this C code? int main() { char c; int i = 0; FILE *file; file = fopen("test.txt", "w+"); fprintf(file, "%c", 'a'); fprintf(file, "%c", -1); fprintf(file, "%c", 'b'); fclose(file); file = fopen("test.txt", "r"); while ((c = fgetc(file)) != -1) printf("%c", c); return 0; }

Mark the correct option

8. What is short int in C programming?

Mark the correct option

9. Comment on the output of this C code? int main() { float f1 = 0.1; if (f1 == 0.1) printf("equal\n"); else printf("not equal\n"); }

Mark the correct option

10. Comment on the output of this C code? int main() { float f1 = 0.1; if (f1 == 0.1f) printf("equal\n"); else printf("not equal\n"); }

Mark the correct option

11. What is the output of this C code (on a 32-bit machine)? int main() { int x = 10000; double y = 56; int *p = &x; double *q = &y; printf("p and q are %d and %d", sizeof(p), sizeof(q)); return 0; }

Mark the correct option

12. Which is correct with respect to size of the datatypes?

Mark the correct option

13. What is the output of the following C code(on a 64 bit machine)? union Sti { int nu; char m; }; int main() { union Sti s; printf("%d", sizeof(s)); return 0; }

Mark the correct option

14. What is the output of this C code? int main() { float x = 'a'; printf("%f", x); return 0; }

Mark the correct option

15. Which of the datatypes have size that is variable?

Mark the correct option

Index of Questions