Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Language: C Part 1: Do While and Switch Case In the file onceplus.c, there is a function called process which takes one argument, a

Programming Language: C

Part 1: Do While and Switch Case

In the file onceplus.c, there is a function called process which takes one argument, a single integer, and returns an integer value.

There are also a number of symbolic constants defined at the beginning of the file.

The process function should include a switch case using the argument as its condition value.

For every symbolic constant at the beginning of the tile, there should be a separate case for that value. They should do the following:

For ERROR_404, the switch should print Not Found. on its own line.

For ERROR_403, the switch should print Forbidden. on its own line.

For ERROR_400, the switch should print Bad Request. on its own line.

# define ERROR_404 'a'

# define ERROR_403 'b'

# define ERROR_400 'c'

Also, include a case for EOF.

For EOF, the switch should print End of Stream and then return 0 or FALSE.

In the default case, print Valid input found: and then the argument as an ASCII character followed by a newline character.

If the argument wasnt EOF, then the process function should return 1 or TRUE.

In the main file, write a do while loop to read one character of input from standard input at a time and pass it to the process function as an integer. Since were letting the process function handle EOF, dont cast the input down to an integer just yet.

Use the process functions return value to decide if the loop should continue as the do whiles condition.

This program should only contain ONE (1) instance of the getchar function and NO OTHER INPUT FUNCTIONS!

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

Students also viewed these Databases questions

Question

Solve. 4x 2 = 24

Answered: 1 week ago

Question

Describe loss aversion and myopic loss aversion.

Answered: 1 week ago

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago