Basic C Programming MCQ Questions and Answers

Practice Mode
Showing 10 of 198 questions
Q41
The program fragment int i = 263; purchar (i);
  • A prints 263
  • B prints the ASCII equivalent of 263
  • C rings the bell
  • D prints garbage
Answer: Option C
Q42
Which of the following comments regarding the reading of a string, using scanf (with %s option) and gets, is true ?
  • A Both can be used interchangeably
  • B scanf is delimited by end of line, while gets is not.
  • C scanf is delimited by blank space, while gets is not.
  • D none of the above
Answer: Option C
Q43
The following statement printf ("%f", 9/5); prints
  • A 1.8
  • B 1.0
  • C 2.0
  • D none of the above
Answer: Option D
Q44
The statements printf("%f", (float)9/5);
  • A 1.8
  • B 1.0
  • C 2.0
  • D none of the above
Answer: Option A
Q45
Which of the following are not keywords in C?
  • A printf
  • B main
  • C IF
  • D none of the above
Answer: Option
Q46
The following program fragment unsigned i = 1; int j = -4; printf("%u", i + j ); prints
  • A garbage
  • B -3
  • C aninteger that changes from machine to machine
  • D none of the above
Answer: Option C
Q47
If the following program fragment (assume negative numbers are stored in 2's complement form) unsigned i = 1; int j = -4 ; printf "%u", i + j) ; prints x, then printf ("%d", 8*sizeof (int)); Outputs an integer that is same as (log in the answer are to the base two)
  • A an unpredictable value
  • B 8 * log (x+3)
  • C log (x+3)
  • D none of the above
Answer: Option C
Q48
The following statements for (i = 3; i < 15; i += 3) {printf ("%d", i); ++i; will result in the printing of
  • A 3 6 9 12
  • B 3 6 9 12 15
  • C 3 7 11
  • D 3 7 11 15
Answer: Option C
Q49
If a = 9, b = 5 and c = 3, then the expression (a - a/b * b%c) > a%b%c evaluates to
  • A true
  • B false
  • C invaid
  • D 0
Answer: Option A
Q50
In a for loop, if the condition is missing, then
  • A it is assumed to be present and taken to be false
  • B it is assumed to be present and taken to be true
  • C It results a syntax error
  • D execution will be terminated abruptly
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test