Top

Discussion

What will be the output of the following C code?

#include
void f()
{
    #define sf 100
    printf("%d",sf);
}
int main()
{
    #define sf 99;
    f();
    printf("%d",sf);
}

 

  • A.error
  • B.100
  • C.99
  • D.10099

Answer: A

Macro definition is global even if it is appears within the function scope. In this case the macro sf is defined in the function f(). Hence it results in a compile time error.

No comment is present. Be the first to comment.
Loading…

Post your comment