Tuesday, December 30, 2014

Else if ladder and simple if pro in C



Else if ladder

#include
#include
void main()
{
int mark;
clrscr();
          printf("Enter your  English mark");
          scanf("%d",&mark);
          if(mark>=80)
                   {
                   printf("You have obtained the first class in english");
                   }
          else if(mark>=60)
                   {
                   printf("You have obtained the second class in english");
                   }
          else if(mark>=35)
                   {
                   printf(" You are pass in english");
                   }
          else
                   {
                   printf("You are fail english");
                   }
getch();
}

Output
          
          Enter ur English mark
          63
          You have obtained the second class in English

Program2

#include
#include
void main()
{
int a,b,c;
clrscr();
          printf("Enter the a,b,c value");
          scanf("%d%d%d",&a,&b,&c);
if(a>b&a>c)
          {
          printf("A is big number");
          }
else if(b>a & b>c)
          {
          printf(" B is big number");
          }
else if(c>a & c>b)
          {
          printf(" C is big number");
          }
else
          {
          printf(" Invalid numbers");
          }
getch();
}

Output
        
          Enter the a,b,c values
          15
          5
          25
          C is big number

Simple if

#include
#include
void main()
{
int mark;
clrscr();
          printf("Enter ur tamil mark");
          scanf("%d",&mark);
          if(mark>=35)
                   {
          printf("U r pass");
          }
getch();
}

Output
         
         Enter ur tamil mark
          53
          U r pass

No comments:

Post a Comment