?
What will be output after executing following code?
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
}
#include<stdio.h>
# define a 10
void main()
{
printf("%d..", a);
foo();
printf("%d", a);
}
void foo()
{
#undef a
#define a 50
}
Join the Discussion
Login to post a comment or share your explanation.
Loginlets discuss
it should be 10..50, why it is 10..10
just like the previous sum
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.