What will be the output of the following C code? [code]#include<stdio.h> enum 123hoidap { a,b,c=5 }; enum 123hoidap s; main() {

What will be the output of the following C code?
Code:
#include<stdio.h>
enum 123hoidap
{
    a,b,c=5
};
enum 123hoidap s;
main()
{
    c++;
    printf("%d",c);
}
A. Error
B. 5
C. 6
D. 2
 
Answer: a
Explanation: The above code results in an error because it is not possible to modify the value of enum constants. In the above code, we have tried to increment the value of c. This results in an error.
 

Tìm kiếm

Back
Top