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
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 |
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 |
Where does the name "C" come from, anyway?
how to swap 2 numbers in a single statement?
what is pointer
difference between loading and linking
what is the use of c program?
4 Answers Synergy, Web Synergies,
State the difference between realloc and free.
What is the maximum length of an identifier?
Give the Output : * * * * * * * * * *
explain what are pointers?
Explain how can I right-justify a string?
What is Lazy evaluation in C? Give an example.
What is time complexity c?