Why the below program throughs error during compilation?

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

main()
{

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

Answers were Sorted based on User's Feedback



Why the below program throughs error during compilation? #include<stdio.h> #include<con..

Answer / 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

Why the below program throughs error during compilation? #include<stdio.h> #include<con..

Answer / modassir alam

TWO or any enum variable not hold memory address hence error

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

Can the “if” function be used in comparing strings?

0 Answers  


How to reverse a string using a recursive function, with swapping?

5 Answers  


9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?

1 Answers  


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

2 Answers   Ignou,


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

0 Answers   Wipro,


What is static and auto variables in c?

0 Answers  


Explain how can you check to see whether a symbol is defined?

0 Answers  


Differentiate between null and void pointers.

0 Answers   TCS,


main() { int i; printf("%d",scanf"%d",&i))//if the input is 12 24 34 then wat will be the output }

2 Answers  


Write program to remove duplicate in an array?

0 Answers  


i need all types of question paper releted to "c" and other language.

0 Answers  


Can i use Two or More Main Funtion in any C program.?

4 Answers  


Categories