C Programming Multiple Choice Question - Preprocessor And Macros

This section focuses on the "Preprocessor And Macros" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. What is the output of this program?

        
#include <stdio.h>
#define int char
main()
{
  int i=50;
  printf ("sizeof (i) =%d", sizeof (i));
}

A. 2
B. 4
C. 8
D. 1

View Answer


2. What is the output of this program?

#include <stdio.h> 
#define x 3
int main()
{
  int i;
  i = x*x*x;
  printf("%d",i);
  return 0;
}

A. 27
B. x is not declared
C. No output
D. Garbage value

View Answer


3. What is the output of this program?

#include <stdio.h> 
#include  <stdlib.h>
#define square(x) x*x
int main()
{
  int i;
  i = 27/square(3);
  printf("%d",i);
  return 0;
}

A. 9
B. Compilation error
C. 3
D. 27

View Answer


4. What is the output of this program?

#include <stdio.h>
#define i 5
int main()
{
  #define i 10
  printf("%d",i);
  return 0;
}

A. Compilation error
B. 10
C. 5
D. Runtime error

View Answer


5. What is the output of this program?

#include <stdio.h>
#define clrscr() 17
int main()
{
  clrscr();
  printf("%d",clrscr());
  return 0;
}

A. Compilation error
B. Runtime error
C. 17
D. none of the above

View Answer


6. What is the output of this program?

		   
#include <stdio.h>
int main()
{
  printf("%d",30);
  return 0;
}

A. Runtime Error
B. Garbage value
C. Compilation error
D. 30

View Answer


7. What is the output of this program?

#include <stdio.h>
#define p 17;
int main()
{
  printf("%d",p);
  return 0;
}

A. Garbage value
B. Runtime error
C. 17
D. Compilation error

View Answer


8. Which statment is true about the given code ?

#include <stdio.h>
enum colors {lets,find,course};
int main()
{
  printf("%d %d %d",course,lets,find);
  return 0;
}

A. 3 1 2
B. 0 1 2
C. 2 0 1
D. 1 0 2

View Answer


9. What is the Error of this program?

#include <stdio.h>
#define CONDITION(x) 
printf("letsfindcourse");                         
int main()
{
  CONDITION(0);
  return 0;
}

A. letsfindcourse
B. Compilation error
C. Runtime error
D. None of the above

View Answer


10. How will you free the memory allocated by the following program?

#include <stdio.h>
#define CONDITION(x)
printf("letsfindcourse");                         
int main()
{
  CONDITION(0);
  return 0;
}

A. Runtime Error
B. letsfindcourse
C. Compilation error
D. None of the above

View Answer




Also check :


Discussion


* You must be logged in to add comment.