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

3/5

Page

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

What will be output after executing following code?
#include<stdio.h>
# define a 10
void main()
{
    printf("%d..", a);
    foo();
    printf("%d", a);
}
void foo()
{
   #undef a
   #define a 50
}

Select an option to see the answer and solution.

The output of the following program is:
#define f(g,g2) g##g2
void main()
{
   int var12=100;
   printf("%d", f(var,12));
}

Select an option to see the answer and solution.

Find the output of the following program.
#define INC(X) X++
void main()
{
   int x=4;
   printf("%d", INC(x++));
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
#define max 20
main()
{
    #ifndef max
    #define min 10
    #else
    #define min 30
    #endif
    printf("%d",min);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#define display(text) "$" #text
main()
{
    printf(display(hello	   world));
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define Shyam(x)  #x
int main()
{
    int marks=100;
    printf("value of %s is = %d\n",Shyam(marks),marks);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
#define max 100
void main()
{
    #if(max%10)
    printf("Exam");
    #endif
    printf("Veda");
}

Select an option to see the answer and solution.

. . . . . . . . is the preprocessor directive which is used to end the scope of #ifdef.

Select an option to see the answer and solution.

In the directive #pragma pack(n), if the value of 'n' is given to be 5, then what happens?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
#define INDIA 1
#define US 2
#define CC US
main()
{
    #if CC==INDIA
    printf("Rupee");
    #elif CC==US
    printf("Dollar");
    #else
    printf("Euro");
    #endif 
}

Select an option to see the answer and solution.

What will be the output of the following C code, if it is run on a 32 bit platform?
#include<stdio.h>
#pragma(1)
struct test
{
    int i;
    char j;
};
main()
{
    printf("%d",sizeof(struct test));
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define p( m ) printf( "t*" #m " = %s", t##m )
char tram[]="tram";
int main()
{
    int x;
    x=p(ram);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
#define sf 10
main()
{
    if(sf==100)
        printf("good");
    else
    {
        printf("bad");
        sf=100;
    }
    printf("%d",sf);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
void main()
{
    #ifndef max
    printf("hello");
    #endif
    printf("hi");
}

Select an option to see the answer and solution.

The following C code results in an error.
#include <stdio.h>
#define world( n ) printf( "t^^" #n" = %c", t##n )
int t3=1;
int main()
{
   world(3);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#define F abc
#define B def
#define FB(arg) #arg
#define FB1(arg) FB(arg)
main()
{
    printf(FB(F B));
    FB1(F B);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define p( n,m ) printf( "%d", m##n )
int main()
{
   p(3,4);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#define example(s,n) #s #n
main()
{
    printf(example(hello,world));
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define hello( n ) a##n
int a3;
int main()
{
    int x;
    x=hello(3);
    if(x!=0)
        printf("hi");
    else
        printf("good");
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
#define hello 
main()
{
    #ifdef hello
    #define hi 4
    #else
    #define hi 5
    #endif
    printf("%d",hi);
 
}

Select an option to see the answer and solution.