ExamVeda
Login
Home
41
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
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
42
The output of the following program is:
#define f(g,g2) g##g2
void main()
{
   int var12=100;
   printf("%d", f(var,12));
}
Discuss
Answer & Solution
Answer: Option D
Solution:

## is token pasting operator which simply combines all the parameters of macro into one variable.
So, in f(var, 12), var and 12 combines to form var12 and replaces the f(var, 12) and hence the output is 100.

43
Find the output of the following program.
#define INC(X) X++
void main()
{
   int x=4;
   printf("%d", INC(x++));
}
Discuss
Answer & Solution
Answer: Option D
Solution:

L value is required for this expression (x++) which is illegal.

44
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);
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
45
What will be the output of the following C code?
#define display(text) "$" #text
main()
{
    printf(display(hello	   world));
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
46
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;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
47
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");
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
48
. . . . . . . . is the preprocessor directive which is used to end the scope of #ifdef.
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
49
In the directive #pragma pack(n), if the value of 'n' is given to be 5, then what happens?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
50
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 
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board