Tuesday, December 30, 2014

C using if else pro



Program1

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

Output
          
        Enter ur tamil mark
          43
          U r pass

Program2

#include
#include
void main()
{
int age,tamil,english,maths,total;
clrscr();
          printf("Enter the age\n");
          scanf("%d",&age);
          printf("Enter tamil,English and maths marks\n");
          scanf("%d%d%d",&tamil,&English,&maths);
          total=tamil+English+maths;
          printf("Total = %d\n",total);
if(age>=18)
          {
          printf("You are selected\n");
          }
else
          {
          printf("You are not selected\n");
          }
if(total>=250)
          {
          printf("1st Class");
          }
else
          {
          printf("2nd Class");
          }
getch();
}

Output
         
          Enter the age
          18
          Enter tamil, English and maths marks
          90
          85
          70
          Total           :         245
          You are selected
2nd Class

No comments:

Post a Comment