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

How can a program be made to print the line number where an error occurs?

652


an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational

812


What is getch() function?

649


How many types of errors are there in c language? Explain

573


What do you mean by dynamic memory allocation in c?

652






What is gets() function?

673


What is the difference between text files and binary files?

679


Difference between MAC vs. IP Addressing

643


What is oops c?

613


What is adt in c programming?

611


What is wrong with this initialization?

593


What is c++ used for today?

669


What are local static variables? How can you use them?

647


Explain what math functions are available for integers? For floating point?

616


What is the general form of #line preprocessor?

587