Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

  Take Quiz (Monsoon) Beta Version !!
  Do You have Qs. in your Mind ??? Ask it as Qs. or MCQs or create it as polling Live Now !!

C Programming :: C Preprocessor

Home > C Programming > C Preprocessor > General Questions

1 / 33

 What will be output of the following "c" code?

#include
#define max(a,b) (a>b)? a:b
int main()
{
int a,b; a=3; b=4;
printf("%d",max(a,b));
return 0;
}

Answer: Option B

Explanation:

Since, using directive statement the valus of a is less than b which is false condition in the ternery statement results to B value.

Workspace


Tags:  Capgemini

2 / 33

 What will be output of the following "c" code?

#include
#define clrscr() 100
main()
{
clrscr();
printf("%d\n",clrscr());
}

Answer: Option C

Explanation:

Preprocessor executes as a seperate pass before the execution of the
compiler. So textual replacement of clrscr() to 100 occurs.

Workspace


Tags:  No Tags on this question yet!

3 / 33

 What will be output of the following "c" code?

#include
#define int char
void main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}

Answer: Option B

Explanation:

The #define replaces the string int by the macro char

Workspace


Tags:  No Tags on this question yet!

4 / 33

 What will be output of the following "c" code?

#include
#define a 10
void main()
{
#define a 50
printf("%d",a);
}

Answer: Option C

Explanation:

The preprocessor directives can be redefined anywhere in the program. So the most recently assigned value will be taken.

Workspace


Tags:  No Tags on this question yet!

5 / 33

 What will be output of the following "c" code?

#include
#define square(x) x*x
void main()
{
int i;
i = 64/square(4);
printf("%d",i);
}

Answer: Option A

Explanation:

Pre-processor will substitute square(4) by 4*4
so the expression becomes I = 64/4*4 .
Since / and * has equal priority the expression will be evaluated as (64/4)*4 => 16*4 = 64

Workspace


Tags:  No Tags on this question yet!

6 / 33

 What will be output of the following "c" code?

#include
#define FALSE -1
#define TRUE 1
#define NULL 0
int main() {
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
}

Answer: Option B

Explanation:

Preprocessor doesn't replace the values given inside the double quotes. The check by if condition is boolean value false so it goes to else. In second if -1 is boolean value true hence "TRUE" is printed.

Workspace


Tags:  No Tags on this question yet!

7 / 33

 What will be output of the following "c" code?

#include
#define f(g,g2) g##g2
int main()
{
int var12=100;
printf("%d",f(var,12));
return 0;
}

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

8 / 33

 What will be output of the following "c" code?

#include
#define prod(a,b) a*b
void main()
{
int x=3,y=4;
printf("%d",prod(x+2,y-1));
}

Answer: Option A

Explanation:

The macro expands and evaluates to as:
x+2*y-1
=> x+(2*y)-1
=> 3+(2*4)-1 => 10

Workspace


Tags:  No Tags on this question yet!

9 / 33

 What will be output of the following "c" code?

#include
#ifdef something
int some=0;
#endif
void main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
}

Answer: Option C

Explanation:

This is a very simple example for conditional compilation.
The name something is not already known to the compiler making the declaration int some = 0; effectively removed from the source code.

Workspace


Tags:  No Tags on this question yet!

10 / 33

 What will be output of the following "c" code?

#include
#if something == 0
int some=0;
#endif

void main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
}

Answer: Option B

Explanation:

This code is to show that preprocessor expressions are not the same as the ordinary expressions. If a name is not known the preprocessor treats it to be equal to zero.

Workspace


Tags:  No Tags on this question yet!