if条件语句的使用和具体细节问题
一个if语句中有且只有一个 if,else if可以有多个,else最多只有一个。
/*
Date:2019年8月1日
Author:Zoey Wang
Function:判断输出成绩所属的成绩段
if条件语句的形式和使用
*/
#include<stdio.h>
int main(void)
{
double a; //double 双精度浮点型
printf("please input your score:");
scanf("%lf", &a);
/* 方法一
if(a<0 || a>100) // || 表示逻辑或运算符,如果两边表达式一个真,则整个表达式为真,两边为假,整个为假
printf("Your score is not correct\n");
if(a>=0 && a<60) // && 表示你逻辑与运算符,如果两边表达式全真,则整个表达式为真,如果有一个为假,整个为假
printf("Sorry, you failed this exam...\n");
if(a>=60 && a<=100)
printf("Congratulations, you passed the exam!!\n");
*/
/* 方法二
if(a<0 || a>100)
printf("Your score is not correct\n");
else
{
if(a<60)
printf("Sorry, you failed this exam...\n");
else