1:
#include <stdio.h>
/// if else basic:
int main()
{
int a;
printf("Please enter a number greter than five:");
scanf("%d",&a);
if(a>=5)
printf("%d",a*a);
else
printf("ERROR!!!\n");
return 0;
}
output: depend on your value
2:
#include <stdio.h>
///nested if else:
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
printf("The result is:%d",a);
else
printf("The result is:%d",c);
}
else
{
if(b>c)
printf("The result is:%d",b);
else
printf("The result is:%d",c);
}
return 0;
}
output: depend on your value
3:
#include <stdio.h>
///if else ladder:
int main()
{
int mark;
scanf("%d",&mark);
if(mark>=80) printf("your grade point is:+A");
else if(mark>=70) printf("your grade point is:A");
else if(mark>=60) printf("your grade point is:-A");
else if(mark>=50) printf("your grade point is:B");
else if(mark>=40) printf("your grade point is:C");
else printf("Failed!!!");
return 0;
}
output: depend on your value
No comments:
Post a Comment