Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING UNIX/LINUX COMMAND LINE IN TERMINAL. example of command for a C program: gcc -Wall -Wextra -o q_ex1 q_example.c 4. The purpose of this exercise

USING UNIX/LINUX COMMAND LINE IN TERMINAL.

image text in transcribed

example of command for a C program: gcc -Wall -Wextra -o q_ex1 q_example.c

4. The purpose of this exercise is to practice reading from standard input and basic error checking in C You will need to write, compile and execute a C program from scatch. Be sure to make your program simple and its logic straightforward (a) In a new file named lab6_inputs.c, create a basic C program consisting of a single main) function. Declare and initialize one variable of each of the following types: int, char, double and float. Use a do-while loop together with scanf (3) and printf (3) to continuously prompt the user to enter four values of the appropriate type on standard input. Store the input received in your four variables then print a message to the user indicating how many items were read and the value of each item Your do-while loop should stop if the EOF (end of file) character is read from standard input or if an invalid number of input items is received, at which point your program should terminate Recall the following semantics of scanf (3) paraphrased from its man page RETURN VALUE On success, scanf ) returns the number of input items successfully matched and assigned; this can be fewer than provided for, or even zero, in the event of an early matching failure. The value EOF is returned if the end of input is reached before either the first successful conversion or a matching failure occurs. EOF is also returned if a read error occurs You will hand in lab6_inputs.c with this lab, so there is nothing to show in lab6.txt (b) Compile your C program using the necessary option(s) to name the resultant executable lab6_inputs. Have the C compiler perform extra checks for potentially problematic situations by using the -Wall and -Wextra options. Show a log of successful compilation (no warnings or errors) in lab6.txt (c) Run your executable 1ab6_inputs from part 4b at least twice to ensure it is working. Test your program with several lines of valid input followed by the EOF character or a line of invalid input Your program should terminate if the EOF character is sent from the console (Ctrl D) or an invalid number of inputs are provided. Show a log of your testing in lab6.txt

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago