Else-if

Code to find greatest number


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter a,b and c");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
{
printf("greatest number=%d",a);
}
else if((b>c)&&(b>a))
{
printf("greatest number=%d",b);
}
else
{
printf("greatest number=%d",c);
}
getch();
}


Output







Code to check alphabet is vowel or consonant


#include<stdio.h>
#include<conio.h>
void main()
{
char a;
printf("Enter any alphabet");
scanf("%C",&a);
if((a=='a')||(a=='e')||(a=='i')||(a=='o')||(a=='u'))
{
printf("It is a vowel");
}
else
{
printf("It is a consonant");
}
getch();
}


Output







Code for marks grade


#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("Enter marks scored");
scanf("%d",&m);
if(m>=90)
{
printf("Merit");
}
else if((m>=80)&&(m<90))
{
printf("First");
}
else if((m>=70)&&(m<80))
{
printf("Second");
}
else if((m>=60)&&(m<70))
{
printf("Third");
}
else
{
printf("Fail");
}
getch();
}

Output







Code for week according to number


#include<stdio.h>
#include<conio.h>
void main()
{
int d;
printf("Enter any number from 1 to 7");
scanf("%d",&d);
if(d==1)
{
printf("Sunday");
}
else if(d==2)
{
printf("Monday");
}
else if(d==3)
{
printf("Tuesday");
}
else if(d==4)
{
printf("Wednesday");
}
else if(d==5)
{
printf("Thursday");
}
else if(d==6)
{
printf("Friday");
}
else if(d==7)
{
printf("Saturday");
}
else
{
printf("Enter a valid number");
}
getch();
}


Output















Comments

Popular posts from this blog

Code for pattern 6

Code to check leap year