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;
}

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 5 types of inheritance in c ++?

755


What is the meaning of ?

800


What is the purpose of & in scanf?

830


Function calling procedures? and their differences? Why should one go for Call by Reference?

827


Write a program to find the biggest number of three numbers in c?

805


List a few unconditional control statement in c.

755


Explain what is the difference between the expression '++a' and 'a++'?

871


Can we use any name in place of argv and argc as command line arguments?

820


What is the difference between exit() and _exit() function?

784


How can I swap two values without using a temporary?

822


What is null character in c?

862


What is union in c?

841


Why c is called free form language?

758


How do shell structures work?

785


Why ca not I do something like this?

780