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; }
1.a
2.Infinite loop
3.Depends on what fgetc returns
4.Depends on the compiler
Comment on the output of this C code? int main() { float f1 = 0.1; if (f1 == 0.1) printf("equal "); else printf("not equal "); }
1.equal
2.not equal
3.Output depends on compiler
4.None of the mentioned
Comment on the output of this C code? int main() { float f1 = 0.1; if (f1 == 0.1f) printf("equal "); else printf("not equal "); }
1.equal
2. not equal
3.Output depends on compiler
4.None of the mentioned
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 ", a[i]); else printf("FAIL "); }
1.The compiler will flag an error
2.Program will compile and print the output 5
3.Program will compile and print the ASCII value of 5
4.Program will compile and print FAIL for 5 times
The format identifier '%i' is also used for _____ data type?
1.char
2.int
3.float
4.double
What is short int in C programming?
1.Basic data type of C
2.Qualifier
3.short is the qualifier and int is the basic datatype
4.All of the mentioned.
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; }
1.8
2.5
3.4
4.9
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; }
1.p and q are 4 and 4
2.p and q are 4 and 8
3.Compiler error
4. p and q are 2 and 8
What is the output of this C code? int main() { char chr; chr = 128; printf("%d ", chr); return 0; }
1.128
2.- 126
3. Depends on the compiler
4.None of the mentioned
What is the output of this C code? int main() { float x = 'a'; printf("%f", x); return 0; }
1.a
2.run time error
3.a.0000000
4.97.000000
What is the size of an int data type?
1.4 Bytes
2.8 Bytes
3.Depends on the system/compiler
4.Cannot be determined.
Which data type is most suitable for storing a number 65000 in a 32-bit system?
1.short
2.int
3.long
4.double
Which is correct with respect to size of the datatypes?
1. char > int > float
2.int > char > float
3.char < int < double
4.double > char > int
Which of the datatypes have size that is variable?
1.int
2. struct
3.float
4.double
Which of the following is a User-defined data type?
1.typedef int Boolean;
2.typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
3.struct {char name[10], int age};
4.All of the mentioned