problems n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Problems PowerPoint Presentation
Download Presentation
Problems

Loading in 2 Seconds...

play fullscreen
1 / 4

Problems - PowerPoint PPT Presentation


  • 109 Views
  • Uploaded on

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.

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

PowerPoint Slideshow about 'Problems' - palmer


An Image/Link below is provided (as is) to download presentation

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
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

grades
Grades
  • #include <stdio.h>
  • 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);
  • }
grades 2
Grades 2
  • #include <stdio.h>
  • 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);
  • }
calculator
Calculator

#include <stdio.h>

int main(void) {

intOper;

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

}

return(0);

}