Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problems Reads a letter grade from user and displays the corresponding range for that letter grade (A  90-100, B  80-89, C  70-79, D  60-69, otherwise.

Similar presentations


Presentation on theme: "Problems Reads a letter grade from user and displays the corresponding range for that letter grade (A  90-100, B  80-89, C  70-79, D  60-69, otherwise."— Presentation transcript:

1 Problems Reads a letter grade from user and displays the corresponding range for that letter grade (A  90-100, B  80-89, C  70-79, D  60-69, otherwise F) Modify the above problem to accept lower or uppercase letter grades. Write a program for a simple calculator which asks the user to select which operation (+, -, *, /, %), then asks for two numbers, displays the result SECENG 1111

2 Grades #include int main(void) { char LtrGrd; printf("Please enter Letter Grade: "); scanf("%c", &LtrGrd); switch (LtrGrd) { case 'A': printf("Your grade is between 90 and 100\n"); break; case 'B': printf("Your grade is between 80 and 89\n"); break; case 'C': printf("Your grade is between 70 and 79\n"); break; case 'D': printf("Your grade is between 60 and 69\n"); break; case 'F': printf("Your grade is less than 60\n"); break; default: printf("The letter grade entered is not valid\n"); } return(0); }

3 Grades 2 #include int main(void) { char LtrGrd; printf("Please enter Letter Grade: "); scanf("%c", &LtrGrd); switch (LtrGrd) { case 'A': case 'a': printf("Your grade is between 90 and 100\n"); break; case 'B': case 'b': printf("Your grade is between 80 and 89\n"); break; case 'C': case 'c': printf("Your grade is between 70 and 79\n"); break; case 'D': case 'd': printf("Your grade is between 60 and 69\n"); break; case 'F': case 'f': printf("Your grade is less than 60\n"); break; default: printf("The letter grade entered is not valid\n"); } return(0); }

4 Calculator #include int main(void) { intOper; doublex, y; printf("(1) Add\n"); printf("(2) Subtract\n"); printf("(3) Multiply\n"); printf("(4) Divide\n"); printf("Please enter your choice: "); scanf("%d", &Oper); printf("Please enter two operands: "); scanf("%lf%lf", &x, &y); switch (Oper) { case 1:printf("A + B = %.2f\n", x+y); break; case 2:printf("A - B = %.2f\n", x-y); break; case 3:printf("A * B = %.2f\n", x*y); break; case 4:printf("A / B = %.2f\n", x/y); break; default:printf("The selection is not valid\n"); } return(0); }


Download ppt "Problems Reads a letter grade from user and displays the corresponding range for that letter grade (A  90-100, B  80-89, C  70-79, D  60-69, otherwise."

Similar presentations


Ads by Google