Machine-translated by Google. Questions are authored in English.
Top

Discussion

What will be the output of the following C code if input given is 2?

#include <stdio.h>
enum day
{
    a,b,c=5,d,e
};
main()
{
    printf("Enter the value for a");
    scanf("%d",a);
    printf("%d",a);
}

 

  • A.2
  • B.3
  • C.Error

Answer: C

The code shown above results in an error. This is because memory is not allocated for constants in enum. Thereore ampersand(&) cannot be used with them. Also, a value has already been assigned to ‘a’, which cannot be changed.

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

Post your comment

Please log in or register to post a comment.