Wednesday, September 25, 2013

C Programs of else if

Using else if statement, Wrtie a C program to read your age, if it is less than 100 then display message "you are pretty young", if age is equal to hundred the display message " you are old",  if age is greater than 100, then display message" you are really old".

#include <stdio.h>
#include <stdio.h>
void  main()                           
{
 clrscr();
 int age;
 printf( "Please enter your age" );
 scanf( "%d", &age );
 if ( age < 100 )
 {              
     printf ("You are pretty young!\n" );
  }
  else if ( age == 100 )
   {
     printf( "You are old\n" );      
    }
  else
   {
    printf( "You are really old\n" );    
    }
getch();

}



No comments:

Post a Comment