Sail E0 Webinar

MCQs

Total Questions : 43 | Page 5 of 5 pages
Question 41.


What would be output of the program ?


#include<stdio.h>
#define SWAP(a, b) int t; t=a, a=b, b=t;
int main()
{
int a=10, b=12;
SWAP(a, b);
printf("a = %d, b = %d\n", a, b);
return 0;
}
  1.    a = 10, b = 12
  2.    a = 12, b = 10
  3.    Error: Declaration not allowed in macro
  4.    Error: Undefined symbol 't'
 Discuss Question
Answer: Option B. -> a = 12, b = 10


The macro SWAP(a, b) int t; t=a, a=b, b=t; swaps the value of the given two variable.



Step 1: int a=10, b=12; The variable a and b are declared as an integer type and initialized to 10, 12 respectively.



Step 2: SWAP(a, b);. Here the macro is substituted and it swaps the value to variable a and b.


Hence the output of the program is 12, 10.



Question 42.

If the file to be included doesn't exist, the preprocessor flashes an error message


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True


Question 43.

The c preprocessor can trap simple errors like missing declarations,nested comments or mismatch of braces


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False


Latest Videos

Latest Test Papers