Thursday 14 March 2013

switch statement with default case at top


main()
{
    int i=3;
    switch(i)
     {
        default:printf("zero");
        case 1: printf("one");
            break;
       case 2:printf("two");
           break;
      case 3: printf("three");
           break;
      } 
}
Answer :
three
Explanation :
The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.


Blog Author: Vijay Kumar

Go to: Java Aptitude

No comments:

Post a Comment