Give a percentile grade, require the output grade a,b,c,d,e. More than 90 points for the a,80~89 divided into b,70~79 divided into c,60~69 divided into d,60, the following is E

Source: Internet
Author: User
Tags printf require

1, give a percentile grade, require output grade a,b,c,d,e. More than 90 points for a,80~89 divided into b,70~79 divided into c,60~69 divided into d,60 sub-division of the following E. Requirements:

(1) using the IF statement and the switch statement respectively;

(2) When entering illegal data (such as negative numbers), you should give the "input data error" information

Switch Statement implementation:

#include <stdio.h>
int main ()
{
int score;
printf ("Input student's score: \ n");
scanf ("%d", &score);
if (score<0 | | score>100)
{
printf ("Data entered illegally!\n");
}
Else
{
Switch (SCORE/10)
{
Case 0:
Case 1:
Case 2:
Case 3:
Case 4:
Case 5:printf ("the Class of the classmate: e\n");
Case 6:printf ("the Class of the classmate: d\n");
Case 7:printf ("the Class of the classmate: c\n");
Case 8:printf ("the Class of the classmate: b\n");
Case 9:
Case 10:printf ("the Class of the classmate: a\n");
}
}
return 0;
}


If statement implementation: #include <stdio.h>
int main ()
{
int score;
printf ("Input student's score: \ n");
scanf ("%d", &score);
if (score<0 | | score>100) {
printf ("Data entered illegally!\n");
}
else{
if (score>90) {
printf ("The student's rank is: A");
}
if (score>=80 && score<=90) {
printf ("The student's rank is: B");
}
if (score>=70 && score<=79) {
printf ("The student's rank is: C");
}
if (score>=60 && score<=69) {
printf ("The student's rank is: D");
}
if (score>=0&&score<=59) {
printf ("The student's rank is: E");
}
}
return 0;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.