Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Write a C program based on the output and given infor. Below: Part a) - keep on reading and processing input, until an integer

1) Write a C program based on the output and given infor. Below:

Part a) - keep on reading and processing input, until an integer -2000 is read.

- use scanf ("%d %c", ..) to read inputs.

- define a Boolean function isDigit(char c) to determine if c represents a digit. We mentioned in class that ANSI-C does not have a type `boolean, instead it uses 0 to represent false, and use non-zero integer to represent true. So, as a general practice in C, your function should return a non-zero number (usually 1) if c is a digit and returns 0 otherwise. Note that you should NOT use if c=='0' c=='1' c=='2' c=='3' c=='9'. Instead, use the one-statement trick that we discussed in class.

- Note that in getting the numerical value of a digit character such as '3', you should NOT use if c=='0' c=='1' c=='2' c=='3' c=='9'. Instead, use the one statement trick that we discussed in class.

- put the definition (implementation) of function isDigit after your main function. and display the prompt and output as shown below:

Enter an integer and a character separated by blank>10 d

Character d is not a digit

Enter an integer and a character separated by blank>20 5

Character '5' is a digit. Total of 20 and 5 is 25

Part b) Uses getchar and putchar to read from the Standard input, and outputs (duplicates) the characters to the Standard output.

- use getchar() and a loop to read characters.

- use putchar() to print the input characters on the standard output.

- do NOT use any other C library functions. Do your own checking and conversion. However, you should NOT use if c=='A' c=='B' c=='C' c=='D' c=='Z'. Instead, use the one-statement trick discussed in class.c

output:

What You Doing?

WHAT YOU DOING?

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

love of humour, often as a device to lighten the occasion;

Answered: 1 week ago

Question

orderliness, patience and seeing a task through;

Answered: 1 week ago

Question

well defined status and roles (class distinctions);

Answered: 1 week ago