Top

Discussion

What will be the output of the following C code if the value of ‘p’ is 10 and that of ‘q’ is 15?

#include
int main()
{
    int p,q;
    printf("Enter two numbers\n");
    scanf("%d",&p);
    scanf("%d",&q);
    #if(4<2>-1)
    printf("%d",q);
    #else
    printf("bye");
    #endif
}

 

  • A.10
  • B.15
  • C.bye
  • D.error

Answer: B

The output of the code shown above is 15. The values given for ‘p’ and ‘q’ are 10 and 15 respectively. Since the condition given for #elif is true, the value stored in ‘q’ will be printed, that is 15.

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

Post your comment