ExamVeda
Login
Home
31
C preprocessor
Discuss
Answer & Solution
Answer: Option E
No explanation is given for this question. Let's Discuss on Board
32
A preprocessor command
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
33
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));
}
Discuss
Answer & Solution
Answer: Option B
Solution:

Since the #define replaces the string int by the macro char.
So, here i is a variable of type char and not int.

34
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); 
}
Discuss
Answer & Solution
Answer: Option B
Solution:

The macro call square(4) will be substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority and associativity left to right, so the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64.

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

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

36
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.
Discuss
Answer & Solution
Answer: Option E
No explanation is given for this question. Let's Discuss on Board
37
Determine output:
#include<stdio.h>
#define clrscr() 100
void main()
{
      clrscr();
      printf("%dn", clrscr());
}
Discuss
Answer & Solution
Answer: Option C
Solution:

Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this :

void main()
{
      100;
      printf("%d\n", 100);
}

Note: 100; is an executable statement but with no action. So it doesn't give any problem.

38
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));
}
Discuss
Answer & Solution
Answer: Option C
Solution:

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

39
In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
40
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++);
}
Discuss
Answer & Solution
Answer: Option E
Solution:
main.c: In function ‘main’:
main.c:5:12: error: lvalue required as increment operand
i = max++;