Vidyalelo
C Programming · all questions

C Preprocessor
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

93

Questions

2/5

Page

Pick an option on a question to see the right answer and solution.

In C, how do you use the #ifndef directive to conditionally include code if a macro is not defined?

Select an option to see the answer and solution.

What does the #pragma once directive do in C preprocessing?

Select an option to see the answer and solution.

In C, what is the purpose of the #ifdef directive?

Select an option to see the answer and solution.

What is the purpose of the #pragma warning directive in C preprocessing?

Select an option to see the answer and solution.

In C preprocessing, what is the purpose of the #elifdef directive?

Select an option to see the answer and solution.

What is the result of the #pragma message directive in C preprocessing?

Select an option to see the answer and solution.

What is the purpose of the #undef directive in C preprocessing?

Select an option to see the answer and solution.

In C preprocessing, what is the purpose of the #elifndef directive?

Select an option to see the answer and solution.

What is the result of the #pragma warning directive in C preprocessing?

Select an option to see the answer and solution.

In C, what is the purpose of the #line directive?

Select an option to see the answer and solution.

C preprocessor

Select an option to see the answer and solution.

A preprocessor command

Select an option to see the answer and solution.

What will be the output of the program?
#include<stdio.h>
#define int char 
void main()
{
      int i = 65;
      printf("sizeof(i)=%d", sizeof(i));
}

Select an option to see the answer and solution.

What will be the output of the following program?
#include<stdio.h>
#define square(x) x*x 
void main()
{ 
      int i; 
      i = 64/square(4); 
      printf("%d", i); 
}

Select an option to see the answer and solution.

What will be the output of the program code?
#include<stdio.h>
#define a 10
void main()
{
      #define a 50
      printf("%d", a);
}

Select an option to see the answer and solution.

Choose the correct statement.
I.   The scope of a macro definition need not be the entire program.
II.  The scope of a macro definition extends from the point of definition to the end of the file.
III. New line is a macro definition delimiter.
IV.  A macro definition may go beyond a line.

Select an option to see the answer and solution.

Determine output:
#include<stdio.h>
#define clrscr() 100
void main()
{
      clrscr();
      printf("%dn", clrscr());
}

Select an option to see the answer and solution.

What will be the output of the following program?
#include<stdio.h>
#define prod(a,b)  a*b
void main()
{
      int x=3,y=4;
      printf("%d", prod(x+2,y-1));
}

Select an option to see the answer and solution.

In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h

Select an option to see the answer and solution.

What will be output if you will compile and execute the following c code?
#include<stdio.h>
#define max 5
void main(){
    int i = 0;
    i = max++;
    printf("%d", i++);
}

Select an option to see the answer and solution.