ExamVeda
Login
Home
This question belongs to C Program C Preprocessor
C Preprocessor
?

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
}

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

4 Comments
Dikonda Sursan
Dikonda Sursan 8 years ago
what is the functionality of #undef...
lets discuss
it should be 10..50, why it is 10..10
Umang Mahant
Umang Mahant 9 years ago
Tej Deep coorect!
just like the previous sum
Srikanya Katikala
Srikanya Katikala 9 years ago
correct option is B
since the macro which is defined, is applicable for all the functions mentioned below. so up to the function invocation the macro a = 10
And in the function body, macro a becomes undefined. and again redefined in the function body as a = 50. whatever the changes we have made in the function body is only accessible in the the function. and these modification not applicable outside of that particular function. so macro a is not undefined.
Tej Deep
Tej Deep 10 years ago
Actually it should give error, no proper header file..So the correct answer must be D