Top

Discussion

What will be the output of the following C code?

#define sqr(x) x*x
main()
{
    int a1;
    a1=25/sqr(5);
    printf("%d",a1);
}

 

  • A.25
  • B.1
  • C.5
  • D.error

Answer: A

The output of the code shown above is 25. This is because the arithmetic statement takes the form of: 25/5*5 (which is equal to 1). If the macro had been defined as #define sqr(x) (x*x), the output would have been 1.

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

Post your comment