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 |
What is the basic structure of c?
write function to reverse char array ... without using second array
how can be easily placed in TCS.
What are categories used for in c?
write a program that finds the factorial of a number using recursion?
Is main is user defined function?
What is action and transformation in spark?
Program to trim a given character from a string.
What is the difference between a function and a method in c?
If null and 0 are equivalent as null pointer constants, which should I use?
In the below code, how do you modify the value 'a' and print in the function. You'll be allowed to add code only inside the called function. main() { int a=5; function(); // no parameters should be passed } function() { /* add code here to modify the value of and print here */ }
What is the best style for code layout in c?