Problems

1 / 4

# Problems - PowerPoint PPT Presentation

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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Problems' - palmer

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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

CENG 111

• #include <stdio.h>
• int main(void) {
• char LtrGrd;
• scanf("%c", &LtrGrd);
• switch (LtrGrd) {
• case 'A':
• break;
• case 'B':
• break;
• case 'C':
• break;
• case 'D':
• break;
• case 'F':
• break;
• default:
• printf("The letter grade entered is not valid\n");
• }
• return(0);
• }
• #include <stdio.h>
• int main(void) {
• char LtrGrd;
• scanf("%c", &LtrGrd);
• switch (LtrGrd) {
• case 'A':
• case 'a':
• break;
• case 'B':
• case 'b':
• break;
• case 'C':
• case 'c':
• break;
• case 'D':
• case 'd':
• break;
• case 'F':
• case 'f':
• break;
• default:
• printf("The letter grade entered is not valid\n");
• }
• return(0);
• }
Calculator

#include <stdio.h>

int main(void) {

intOper;

double x, y;

printf("(2) Subtract\n");

printf("(3) Multiply\n");

printf("(4) Divide\n");

scanf("%d", &Oper);

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 letter grade is not valid\n");

}

return(0);

}