int main()
{
int i=1;
switch(i)
{
case '1':
printf("hello");
break;
case 1:
printf("Hi");
break;
case 49:
printf("Good Morning");
break;
}
return 0;
}

Answers were Sorted based on User's Feedback



int main() { int i=1; switch(i) { case '1': printf("hello"); break; case..

Answer / srsabariselvan

The program Results in Error.
it will shows error "Duplicate case".
because '1' is equal to 49(ASCII of character 1).

Is This Answer Correct ?    8 Yes 0 No

int main() { int i=1; switch(i) { case '1': printf("hello"); break; case..

Answer / vishnu nayak

it will display Hi. In case '1', 1 is a character and it is
converted into ascii equivalent and then tested, which is
not equal to 1.

if the code is like this
swithc(i)
{
case 1:
printf("hi");
break;
case 1:
printf("Hello ");
break;

} then it will surly give compilation error.

Is This Answer Correct ?    4 Yes 2 No

int main() { int i=1; switch(i) { case '1': printf("hello"); break; case..

Answer / hussain reddy

error because duplicate case values

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

what is an ERP?

2 Answers   Infotech,


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

0 Answers   Aegis, CDAC, Infosys,


What is the difference between declaring a variable and defining a variable?

0 Answers  


How can I access memory located at a certain address?

3 Answers   Verizon,


Compare interpreters and compilers.

0 Answers  






wite a programme in c to linear search a data using flag and without using flags?

3 Answers   TCS,


What is the difference between far and near in c?

0 Answers  


Define function pointers?

1 Answers  


Write a pro-gramme to determine whether the number is even or odd?

1 Answers  


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

0 Answers  


can u suggest me am in a confusion to choose whether to go to c programming or a software testing . am a graduate in B.sc(electronics).

1 Answers  


What are the properties of union in c?

0 Answers  


Categories