Saturday, September 10, 2011

Coding Puzzle No. 8?

#include <stdio.h>

void main()
{
int i=4;
switch(i)
{
    default:printf("zero");
    case 1: printf("one");
    break;
    case 2:printf("two");
    break;
    case 3: printf("three");
    break;
}
}




Output:
zeroone


ConCept:
Since no case is found as per the given input, so the default case is executed & since there is no break after default case, case 1 also gets executed.

No comments:

Post a Comment