Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programing Homework: to demonstrate using conditional statements and loops. Produce a program code for each task and screenshot outputs **don't produce one whole program

C Programing Homework: to demonstrate using conditional statements and loops.

Produce a program code for each task and screenshot outputs

**don't produce one whole program combining all tasks**

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Task6.1 - Simple Calculator Aim: This task is to demonstrate the knowledge of using conditional statements and loops. The following incomplete command line-based program was written to mimic a simple calculator. At the current state, the program reads the first number (operand-1) digit by digit and allows the user to select the type of operation. #include int main() int count1=0, value=0, number1=0, operation=0; printf("Enter the first operand, one digit at a time... or enter -1 to stop in"); scanf("%d", &value); while(value != -1) number1=number1 10+value; Il new digit is added to the existing operand count1+1; printf("Enter the next digit of first number or 0-1 to stop ... In"); scanf("%d", &value); printf("the first operand = %d In",number); I/ code for the selection of operation printf("Enter the number corresponding to the operation type ... "); printf("1 Addition In"); printf("2 Subtraction in"); printf("3 Multiplication In"); printf("4 Division 1n"); scanf("%d",&operation); return 0; Your task is to complete the above code by adding steps to read the second operand. Then implement the code to calculate the answer based on the selected operation (Addition, Subtraction, Multiplication or Division). Task 6.2 Aim: This task is to demonstrate the knowledge of creating a user defined function and passing arguments to a function. Task 6.2.a This task is an extension of task 6, 1. Your task is to implement user-defined functions to the Task 6.1 code. Using the following function prototype, shift the number reading section of the code from the main to the function. Hint: You might have to use global variables to complete this step. Function prototype: void read number Reuse the function to read number-2. Task 6.2.b Using the following function prototype, shift the operator selection section of the 6.1 code to the function. Hint: You might have to use global variables to complete this step Function prototype: void read_symbolo Task 6.2.c Combine the functions developed in tasks 6.2.a & 6.2.b with main(), complete the implementation of the calculator program. Hint: You might have to use global variables to complete this step. Task 6.3 - Simple Calculator - Extended Aim: This task is to demonstrate the knowledge of creating a user defined function and passing arguments to a function. Extend the code created in Task 6.2 to implement user defined functions with return value. Use the following function prototypes to read number-1, number-2 and the symbol. You must avoid using global variables. Hint: declare local variables in the main and get the return value from the function. int input_number(); int input_symbol(); Submit the working code and screenshots of the output

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions