ALLInterview.com :: Home Page KalAajKal.com
 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                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
#include
main()
{
int i=1,j=2;
switch(i)
 {
 case 1:  printf("GOOD");
                break;
 case j:  printf("BAD");
               break;
 }
}
 Question Submitted By :: Surenda Pal Singh Chouhan
I also faced this Question!!     Rank Answer Posted By  
 
  Re: #include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Answer
# 1
Compiler Error: Constant expression required in function 
main.

Explanation:
The case statement can have only constant expressions (this 
implies that we cannot use variable names directly so an 
error).
            Note:
Enumerated types can be used in case statements.
 
Is This Answer Correct ?    3 Yes 1 No
Surenda Pal Singh Chouhan
 
  Re: #include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Answer
# 2
yeah..itz mainly syntax error..
there shud not be any declaration of variables..in 
case "j"..it must be "case 2"only..
 
Is This Answer Correct ?    3 Yes 1 No
Subha Raman
 
 
 
  Re: #include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Answer
# 3
Compiler Error: Constant expression required in function 
main

instead of using j u we can use case 'j' . 

this is correct answer
 
Is This Answer Correct ?    2 Yes 2 No
Suresh Reddy
 
  Re: #include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Answer
# 4
nopes we cannot use 'j'... because single qutoes ' ' are 
used only for character value.. i.e if it was
char i
switch(i)
then we cud have used it like that..


hence in our case, 
it will give a compiler error...
 
Is This Answer Correct ?    2 Yes 2 No
Shruti
 
  Re: #include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Answer
# 5
if we use the single qutoes' 'at 1 and j the rest of 
program is right because we already decleared the value of i
and i=1 .
       so output should be "GOOD" only. (without" ")
 
Is This Answer Correct ?    1 Yes 0 No
Pravin
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
int a=1,b=2,c=3; printf("%d,%d",a,b,c); What is the output? Verifone14
difference between my-strcpy and strcpy ? Geometric-Software3
In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?  4
How to Clear last bit if it 1 using Macro TURN_OFF_BIT_LAST Adobe2
What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1; TCS10
how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help  2
what is difference b/w extern & volatile variable?? Teleca2
While(1) { } when this loop get terminate is it a infinite loop?  4
4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above Accenture4
which of the following go out of the loopo if expn 2 becoming false a.while(expn 1){...if(expn 2)continue;} b.while(!expn 1){if(expn 2)continue;...} c.do{..if(expn 1)continue;..}while(expn 2); d.while(!expn 2){if(expn 1)continue;..} TCS2
will the program compile? int i; scanf(“%d”,i); printf(“%d”,i);  2
6. Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod() Accenture1
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..  1
What should be keep precautions while using the recursion method?  1
How many ways are there to swap two numbers without using temporary variable? Give the each logic.  6
What is the real difference between arrays and pointers?  11
what is the diference between pointer to the function and function to the pointer?  2
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output? Ramco5
main() { printf("hello%d",print("QUARK test?")); }  4
plz answer....A program that takes 3 variables e.g a,b,c in as seperate parameters and rotates the values stored so that value goes a to b, b to c and c to a .  3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com