C/C /C Multiple Choice Questions Sample Test,Sample questions

Question:
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


Question:
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


Question:
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


Question:
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


Question:
The format identifier '%i' is also used for _____ data type?

1.char

2.int

3.float

4.double


Question:
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.


Question:
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


Question:
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


Question:
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


Question:
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


Question:
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.


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

1.short

2.int

3.long

4.double


Question:
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


Question:
Which of the datatypes have size that is variable?

1.int

2. struct

3.float

4.double


Question:
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


More MCQS

  1. C++ Programming MCQS Set-1
  2. C++ Multiple Choice Questions Set-1
  3. C++ Multiple Choice Questions Set-2
  4. C++ Programming MCQS Set-2
  5. C++ Programming MCQS Set-3
  6. C++ Programming MCQS Set-4
  7. C++ (CPP) MCQ Question with Answer
  8. Advanced c++ multiple choice question(MCQS)
  9. OOPS Quiz Questions and Answers(MCQS)
  10. C Programming - MCQ Questions Set 1
  11. C Programming - MCQ Questions Set 2
  12. C Programming - MCQ Questions Set 3
  13. C Programming - MCQ Questions Set 4
  14. C Programming - MCQ Questions Set 5
  15. C++ programming language MCQ Questions Set 1
  16. C++ programming language MCQ Questions Set 2
  17. C++ programming language MCQ Questions Set 3
  18. C++ programming language MCQ Questions Set 4
  19. C++ programming language MCQ Questions Set 5
  20. C++ Programming -Constructors and Destructors
  21. C++ Programming -OOPS Concepts
  22. C++ Programming - References
  23. C++ Programming - Functions
  24. C MCQS:-The ABC of C
  25. C MCQS Interview Questions
  26. C++ Questions and Answers OOPs Basic Concepts
  27. C++ Questions and Answers Returning Objects
  28. C Programming MCQ Part 1
  29. C Programming MCQ
  30. Computer Science & Engineering C Multiple Choice Questions set 1
  31. Computer Science & Engineering C Multiple Choice Questions set 2
  32. C Multiple Choice Questions C Functions Set 1
  33. C Multiple Choice Questions C Functions Set 2
  34. C Multiple Choice Questions C Operators
  35. C Multiple Choice Questions & AnswersConditional Expressions
  36. C Multiple Choice Questions & Answers Data Types
  37. C Multiple Choice Questions & Answers File Access
  38. Computer Science & Engineering Cloud Computing MCQs Part 1
  39. CPP Programming MCQ Set 1
  40. CPP Programming MCQ Set 2
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!