What will be the output of the following C code?
#include
enum example {a = 1, b, c};
enum example example1 = 2;
enum example answer()
{
return example1;
}
int main()
{
(answer() == a)? printf("yes"): printf("no");
return 0;
}
Answer: B
In the code shown above, the value of example1 is returned by the function answer. The ternary statement prints yes if this value is equal to that of ‘a’ and no if the value is not equal to that of ‘a’. Since the value of ‘a’ is 1 and that returned by the function is 2, therefore no is printed.
Enter details here
What will be the output of the following C code?
#include
enum sanfoundry
{
a=2,b=3.56
};
enum sanfoundry s;
main()
{
printf("%d%d",a,b);
}
Answer: D
No answer description available for this question
Enter details here
If we do not explicitly assign values to enum names, the compiler by default assigns values to ?
Answer:
Enter details here