if 语句:
#include <stdio.h>
void main()
{
int a,b,max;
printf("\n input two number:");
scanf("%d%d",&a,&b);
max=a;
if(max<b)
{
max=b;
}
printf("max=%d",max);
}
if else 语句:
#include <stdio.h>
void main()
{
int a,b;
printf("input two number:");
scanf("%d%d",&a,&b);
if(a>b)
{
printf("max=%d\n",a);
}
else
{
printf("max=%d\n",b);
}
}
if else if 语句:
#include <stdio.h>
void main()
{
int score;
printf("\nplease input a score:");
scanf("%d",&score);
if(score<60)
{
printf("The score is E\n");
}
else if(score>=60 && score<70)
{
printf("The score is D\n");
}
else if(score>=70 && score<80)
{
printf("The score is C\n");
}
else if(score>=80 && score<90)
{
printf("The score is B\n");
}
else if(score>=90 )
{
printf("The score is A\n");
}
}