Top

Discussion

What will be the output of the following C code?

#include
#define sf 10
main()
{
    if(sf==100)
        printf("good");
    else
    {
        printf("bad");
        sf=100;
    }
    printf("%d",sf);
}

 

  • A.100
  • B.bad
  • C.10
  • D.error

Answer: D

The above code will result in an error because a macro cannot be defined using a simple assignment operator. In the code shown above, the value of sf is changed to 100 using the assignment operator. This causes an error.

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

Post your comment