ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2266)
 C++ interview questions  C++ Interview Questions (1121)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (652)
Question
What is the output for the program given below

     typedef enum grade{GOOD,BAD,WORST,}BAD;
     main()
    {
        BAD g1;
        g1=1;
        printf("%d",g1);
     } 
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
1 
Is This Answer Correct ?    9 Yes 0 No
Chris_sreekanth
 
Answer
# 2
error is the answer as 2nd person answer

we can remove error by changing code as follows
typedef enum grade{GOOD,BAD,WORST,} bad;
main()
{
bad g1;
g1=1;
printf("%d",g1);
}

out is 1 for above code






actual error in 1st code is declearing same variable 'BAD'

at two place in enum




if my answer is wrong or any corrections are made by u plz
inform me


molugu.ashwin@gmail.com
 
Is This Answer Correct ?    3 Yes 0 No
Ashwin Kumar
 
 
 
Answer
# 3
In linux you get following error
enum.c:2: error: `BAD' redeclared as different kind of symbol
enum.c:2: error: previous declaration of `BAD'
 
Is This Answer Correct ?    2 Yes 0 No
Fefrf
 
Answer
# 4
error 
Is This Answer Correct ?    1 Yes 0 No
Vijay R15
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
write a c program to remove all the duplicate characters in a string and replace with single character? ex:-input- AAABBBCCC output- ABC HCL 2
program to get the remainder and quotant of given two numbers with out using % and / operators? IBM 10
plz answer..... a program that reads non-negative integer and computes and prints its factorial   2
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?   3
#define f(x) main() { printf("\n%d",f(2+2)); }   5
Why do u use # before include in a C Progam? IBM 8
how to find greatet of 10 numbers without using array?   4
What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1; TCS 12
Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?   6
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }   2
How to add two numbers with using function?   4
Find the output? void main() {float a=2.0; printf("\nSize of a ::%d",sizeof(a)); printf("\nSize of 2.0 ::%d",sizeof(2.0));} IBM 11
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com