Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fix the below code so it uses a while loop instead of just one loop. Using programming in c. Below are the instructions. Thank

Please fix the below code so it uses a while loop instead of just one loop.
Using programming in c. image text in transcribed
Below are the instructions. Thank you so much.
image text in transcribed
image text in transcribed
#include /function declaration void GetIntPointer int numPtr); void Calculations(int num, int *productPtr, int *sumPtr); int main) declare 3 integer variables num.product, sum and int num, product-1, sum-0; call the function GetIntPointer to get a number fronm initialize value the user GetlntPointer(&num): /print the input number onto the screen printfinnThe number is %d in", num); //call the function Calculations to make calcualte the sum and product Calculations(num, &product, &sum); //print the results onto the screen printfi "The sum of number is %d in", sum); printfi "The product of number is %d in'', product); return 0; //function implemantatin to ask, get, and return an integer (by reference) void GetIntPointer(int numPtr) printf"Please enter a number:"); scanf("%d". &"numPtr); input: the number entered by the user (pass by copy) loutput: (product and sum of number void Calculations(int num, int "productPtr, int sumPtr) int i 0; declare variable for i-l; i-num; )/loop num times sumPtr-i; l/sum of number "productPtr = *productPtr * i; //product of number sample output P1@as@ nt@r a number: 5 The number is s The sum of nuber is 15 The product of number is 120 COP2220 Spring 2019 small program (prog6.c) Please do only one step at a time and do not move onto the next step until you have compiled and tested the current step 1. Read the assignment instructions 2. Create an empty project 3. Add the source code file and name the file: lastname firstname progb.c Copy and paste the prog6.c template 4. Change the header comment so that it has your name, date, and a description of the program wbuild run and test, the outline code should compile and execute 5. The first function you will implement will be the Get IntPointer function . Create the function definition (block of code)below the main function Inside this function ask the user for an integer Scanf the integer into numPtr ***build run and test 6. Now it is time to test the GetIntPointer function with a function call 7. Write the statement to call the GetIntPointer function from inside the main function and pass the "address of num to the function Print num onto the screen from the main function to see the number 8. *build run and test 9. The next function we will implement is the product part of the Calculations function Create the function definition below the main function Inside this function you will need to initialize the value at" productPtr and the value at" sumPtr . Create the while loop and do the product calculation Print the result onto the screen after the loop *build run and test 10. Call the Calculations function from the main function pass the num, "address of" product, and "address of" sum print the product and sum in the main function below the function call The product should be calculated and the sum should be 0. e **build run and test 11. The next we will add the sum part of the Calculations function Create the for loop and do the sum calculation Print the result onto the screen after the loop build run and test BEFORE SUBMITTING THE CODE Intro to Programming in C- small program (prog6) Assignment purpose: To compile, build, and execute an interactive program using loops and user defined functions with pass by reference and pass by copy arguments. Submit source code (lastname firatname progb.c) through Canvas .One source code file (unformatted text) will be submitted Name the source code file: lastname firstname prog6. The file name must match the assignment The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas The code must be submitted on time in order to receive credit (11:59 PM on the due date) Late submissions will not be accepted or graded .All programming assigaments are individual work, sharing code is considered cheating Get a number from the user and use that number for loops and to make some calculations Get a number from the user (n) (For example if the user enters a 3, each loop below will repeat 3 times) /lask, get, and return an integer (by reference) void GetIntPointer (int numPtr) //input: the number entered by the user (pass by copy) //Calculates the product of the first (n)numbers using a while loop and store the result in "productPtr //For example, if the user entered a 3, you would calculate 123. //Calculate the sum of the first (n)numbers using a for loop and store the result in sumptr //For example, if the user entered a 3, you would calculate 23 void Calculations(int num, double "productPtr, int sumPtr) NOTE: You will be graded on correct use of functions and correct loop. Remember to initialize the "value at" productPtr and "value at" sunPtr before making the calculations

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions