Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have two questions about this code: 1. What is the purpose of %s in the printf statement in line 54. 2. How can I

I have two questions about this code:
1. What is the purpose of %s in the printf statement in line 54.
2. How can I modify my while condition in order for me to exit the loop since my system does not have the end-of-file(EOF) character. I tried -1 and 0 but they didn't work.
image text in transcribed
image text in transcribed
2 W Fig. 4.7 1904.07. 1 Counting letter grades with switch include 4 5 6 7 . 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 int main(void) + unsigned int a Count = 0; unsigned int Count = 0; unsigned int Count - 0: unsigned int Count = 0; unsigned int fCount = 0; puts("Enter the letter grades."); puts("Enter the EDF character to end input."): int grade: // one grade loop until user types end-of-file key sequence while (Carade - getchar() - EOF) W determine which grade was input switch (grade CX switch nested in while case 'A' // grade was uppercase A case 'a': // or lowercase a HaCount: break; // necessary to exit switch case 'B' // grade was uppercase B case 'b' // or lowercase b ++bCount: break; 27 29 30 31 32 33 34 35 36 37 38 39 40 case 'C' // grade was uppercase C case 'c' or Towercase C ++Count: break; case 'D': // grade was uppercase D case 'd': W or lowercase d dCount: break; case 'F' // grade was uppercase F case 1: // or lowercase f ++fCount: break; 42 43 44 45 46 47 48 49 50 SI case 'in' // ignore newlines case 't'! / tabs case // and spaces in input break; g.4.7 Counting letter grades with switch (Part 1 of 2.) 32 53 54 55 36 ST 55 59 60 61 62 default: // catch all other characters printf("s". "Incorrect letter grade entered."): puts Enter a new grade): break; // optional: will exit switch anyway } // end while // output summary of results puts(" Totals for each letter grade are: printf("A: Su ", acount): printf("B1 Su ", bCount); printf("C: Su ". CCount); printf("o: Suin", dCount); printfCF Non"fCount): 64 65 66 67) Enter the letter grades. Enter the EOF character to end input: a b Incorrect letter grade entered. Enter a new grade. D b NZ Not all system display representation of the cor character Totals for each letter grade are: A 3 C: 3 0:2 F: 1 Fig.4.7 Counting letter grades with switch. (Part 2 of 2.) Reading Character Input In the program, the user enters letter grades for a class. In the while header while (Cgrade - getchar) - EOF) the parenthesized assignment (grade - getchar() executes first. The get (from

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

RECOMMEND how to manage transfers and promotions more effectively.

Answered: 1 week ago