当前位置:网站首页>Scope when multiple else if are nested
Scope when multiple else if are nested
2022-07-16 06:59:00 【Including Ruofei】
Give students a grade respectively ,90 The above points are A,80 The above points are B,70 The above points are C,60 The above points are D , The following are failures .
The question is very simple. , But there are hidden conditions in it ,70 The above refers to
[70,80), The same is true in other regions .
The question is very simple. , I mainly want to talk about the scope
#include<stdio.h>
int main(void)
{
float x,y;
scanf("%f",&x);
if(x>=90)
{
printf("A");
}
else if(x>=80)
{
printf("B");
}
else if(x>=70)
printf("C");
}
else if(x>=60)
{
printf("D");
}
else
printf(" fail, ");
return 0;
}
In the middle of the else if emphasize
Many novices will write else if(x>=80&&x<=90)
This is actually wrong , carry coals to newcastle , Because it's already stay if After statement , So that means if The following statements are all related to if The content after the statement is opposite , That is to say if The following statement defaults to (x<90), Written directly else if(x>=80) that will do . When using, we should pay more attention to this aspect of grammar .
If there are mistakes, please give me more advice , Xiaobai is one .
边栏推荐
猜你喜欢
![[introduction to go language] 08 go language array](/img/f6/6e113d9090a0c58a68b2e379e64500.png)
[introduction to go language] 08 go language array
![[Go语言入门] 14 Go语言goroutine和通道详解](/img/5f/7fef8e5f082f11fe6e29333e622e43.png)
[Go语言入门] 14 Go语言goroutine和通道详解

SSM library management system
![[introduction to go language] 05 go language branch statement](/img/cb/9830418c0e14b40fb15cfb68966426.png)
[introduction to go language] 05 go language branch statement

Holiday study plan from June 24, 2022 to August 26, 2022
![[Go语言入门] 12 Go语言结构体(struct)详解](/img/44/ca65446c5b75bb0860b62906973f85.png)
[Go语言入门] 12 Go语言结构体(struct)详解
![[Go语言入门] 05 Go语言分支语句](/img/cb/9830418c0e14b40fb15cfb68966426.png)
[Go语言入门] 05 Go语言分支语句

LeetCode 刷题 第五天

SSM integration (Reference Version)

SSM integration (classic self version)
随机推荐
go语言json解析库jsoniter的使用(替换标准库encoding/json)
2021-07-31
001 空指针和野指针
I learned JWT single sign on with a cup of tea
LeetCode 刷题 第九天
利用指针编写程序实现在一个字符串的隨意位置上插入一个字符(要求插入字符的位置由用户从键盘输入)。
Obsidian third-party plug-in failed to load
[Go语言入门] 09 Go语言切片详解
LeetCode第十四天
How to classify the consumption ability of members?
【C语言】 大学生考勤管理系统
简单秒杀项目简介
[introduction to go language] 08 go language array
[introduction to go language] 14 go language goroutine and channel details
[introduction to go language] 10 go language map details
ROS communication mechanism
ES6 let, const detailed explanation
ROS 命令
week3
DL第四天