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

How can I open a file so that other programs can update it at the same time?

0 Answers  


What is string length in c?

0 Answers  


How can I swap two values without using a temporary?

0 Answers  


Explain how does free() know explain how much memory to release?

0 Answers  


what are the different storage classes in c?

0 Answers   TCS,






How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

0 Answers  


How does placing some code lines between the comment symbol help in debugging the code?

0 Answers  


What is formal argument?

0 Answers  


plssssss help !!....using array.. turbo c.. create a program that will accept number of words to be consored. .a word must not exceed 10 characters long .the text to be entered will be no longer than 200 characters .there will be no 10 words example: enter number of words to be censor: 5 enter words to censor: windows office microsoft bill gates enter text to censor: bill gates founded microsoft and makes office and windows sample output: <consored> <censored> founded <censored> and makes <censored> and <censored>

1 Answers  


Average of a couple 10 years ago was 25. The average remains same after having a child and twins after 3 years. What is the present age of the first child

10 Answers   IBM, Infosys,


Program to trim a given character from a string.

5 Answers   NetApp,


Explain a pre-processor and its advantages.

0 Answers  


Categories