Why the below program throughs error during compilation?

#include<stdio.h>
#include<conio.h>
enum
{
ZERO,
ONE,
TWO,
};

main()
{

printf("%d",&TWO);
getch();
}

Answer Posted / vadivelt

Since memory shall not be allocated for an enum variable,
accessing address of the same is not possible.

ie.,
Below line is invalid, cos u r trying to access the address
of a constant.

printf("%d",&TWO);

Hence the error.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between structs and unions in c?

771


main() { printf("hello"); fork(); }

950


When can you use a pointer with a function?

755


How can I run c program?

937


How the c program is executed?

865


What is struct node in c?

809


Explain why can’t constant values be used to define an array’s initial size?

1104


What is null character in c?

874


What is the difference between int main and void main in c?

828


What are the keywords in c?

867


How do you define a string?

852


Stimulate calculator using Switch-case-default statement for two numbers

2700


Is null always equal to 0(zero)?

797


Explain about the functions strcat() and strcmp()?

792


In C programming, how do you insert quote characters (‘ and “) into the output screen?

1237