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 (^^)

Technology
©2019-2020 Toolsou All rights reserved,
VUE+Canvas Achieve desktop Pinball brick elimination games C/C++ Memory model 2019PHP Interview questions ( Continuously updated )PHPspringboot2 Separation of front and rear platforms ,token Put in header Pit for verification Vue SpringBoot conduct Excel download element-ui Step on pit record 45 The 12-year-old programmer was turned down , Is the workplace wrong ?Python Web frame Pandas Fundamentals of statistical analysis _ data processing (DataFrame Common operations )Java Misunderstanding —— Method overloading is a manifestation of polymorphism ?