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 do we swap or interchange any 2 numbers without using Temporary variable...Anybody can pls answer it.. Thanks in Advance

8 Answers  


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

0 Answers  


#include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain &#1567;&#1567;&#1567;

4 Answers  


Print all numbers which has a certain digit in a certain position eg: number=45687 1 number=4 2 number=5 etc

4 Answers  


What is stack in c?

0 Answers  






what is an array

5 Answers  


What is meant by realloc()?

0 Answers  


write a c program to find largest number in matrix(in each row,each column, diagonally, and in the whole matrix)? Its urgent.

2 Answers  


Find MAXIMUM of three distinct integers using a single C statement

0 Answers  


How many levels of pointers can you have?

0 Answers  


What are dynamically linked and statically linked libraries?

2 Answers  


in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above

0 Answers  


Categories