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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0qIBKbcBLIs7-8t2B7Vommu0iKUPdLq2AvezONTJOZrSMKa6Pi9jZIhUEhJhyphenhyphen7n8JVudxr5ch2xEZrxDyC2fW5yV9Xjnv01KPSGG_hWdHSl5OodMbY3GxvxmXVJRJnJvxCxFf_WvIsK4/s320/2017-06-22+%25286%2529.png)
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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ6jVJG9yYRB0XaJD29IeH5vkaeDkmMfPSAHlBxyJ6Oyq04Y_GvLJJEV8mRpfoInSh82nsBuro5B3YL7Ia3LTvlaIPai2fG2U-JseZwnUG2E6sp6uRPdM1JvLd_fbaM9FQZ4VDHVIOJE0/s320/2017-06-22+%25288%2529.png)
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();
}
Comments
Post a Comment