switch Statement programming : Give a percentage score , Output grade required A,B,C,D,E.
90 The above points are A,80 to 89 Divided into B,70 to 79 Divided into C,60 to 69 Divided into D,60 It is divided into three parts E.

Thinking of solving problems :score Score entered for , Define a variable a, Give Way score➗a The integral part is used to judge the grade .

notes : This article focuses on the requirements of proficiency switch The format of the statement , To ensure the accuracy of input data , Can be added “default
”, It means to get the result except above (0<a<=10) External , The data entered in the report is incorrect .

The code is as follows
#include<stdio.h> double score; // Double precision real variables int a; // set variable a int main() { printf(
" Please enter your score :\n"); // Score entered scanf("%lf",&score); a=score/10; // Divide the entered score by 10 switch(a) {
case 10:case 9:printf(" What is your grade :A\n");break; case 8:printf(" What is your grade :B\n");break; case
7:printf(" What is your grade :C\n");break; case 6:printf(" What is your grade :D\n");break; case 5:case 4:
case 3:case 2:case 1:case 0:printf(" What is your grade :E\n");break; default:printf(
" Wrong input , Please re-enter \n"); // When the score entered is not in 0~100 Results obtained within the scope of } return 0; }
The results are as follows :
Enter the score as 98, The evaluation grade is A

Enter the score as 56, The evaluation grade is E

Enter the score as 210, be not in 0~100 Within the scope of , Get the results : Wrong input , Please re-enter

I hope you can carefully check your own code errors , Don't give up easily , Calm analysis and continuous progress from it !
If you don't understand, you can put forward it in the comments , Bloggers will try their best to answer (^^)

©2019-2020 Toolsou All rights reserved,
python3 Of tkinter Design of login interface +mysql Import data of database CRC Partial understanding of modular division use MySQL Processing 100 million level data The greatest common divisor and the least common multiple C Language Edition 【 Data structure and algorithm 8】 The maze problem of recursion 2020 year ,Java Is there any future ?【2020 The best little program : You can find all kinds of resources you want ?】element Form validation number type and range An interview of Alibaba outsourcing vue:word Local upload Preview