Friday 3 August 2012

Case structure001


Input a number between 1 to 5 and print the number in word. Give appropriate error message if the number is wrong.


#include <stdio.h>
#include <conio.h>
void main ( )
{
        int         num;
        clrscr ( );
        
        printf ("\n Enter the number between 1 to 5.:"); scanf ("%d",&num);
        
        switch ( num )
        {                       
                  case 1:            
                         printf ("\nONE");
                         break;
                  case 2:
                         printf ("\nTWO");
                         break;
                  case 3:
                         printf ("\nTHREE");
                         break;
                  case 4:
                         printf ("\nFOUR");
                         break;
                  case 5:
                         printf ("\nFIVE");
                         break;
                  default:
                         printf ("\n Out of range.");
        }
        getch ( );
}


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...