Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need this in programming c Description There are 2 Parts to this assignment, both parts are included in one program PART 1 Use the

i need this in programming c
image text in transcribed
Description There are 2 Parts to this assignment, both parts are included in one program PART 1 Use the Getinteger function from small peogram 4 to get a number from the user Get the number from the user (n) (For example if the user enters a 4, cach loop below will repeat 4 times) Calculate the sum of the squares of the first (n) numbers using a for loop. For example, if the user entered a 4, you would calculate 1*1+22+33+4-4 and print the total onte the screen Calculate the product of the squares of the first (n) numbers using a while loop. For example, if the user entered a 4, you would caleulate (1 total onto the sereen 2) 33) (44) and print the Nete: You will be graded en whether or not you used the correct loop as described above, not just on output PART 2 Write a small program that calculates the perimeter and area of a square using pass by reference function Wasks and gets an integer from the user int Getinteger (void) //takes one integer argument and two integer pointer arguments W1. caleulate the area of the square and store the result in areaPtr 2. caleulate the perimeter void CalculateBothSquarelint side, int"areaPtr, int perimeterPtr ) of the square and store the result in perimeterPtr Call all the functions from main Notc: No calculations may be done in the main function Code should be well commented Main function (hints) 1. Declare variables: number, sumTotal, productTotal, length, squarcArca, squarePerimeter 2. Don't forget to initialize sumTotal and productTotal 3. Call Getinteger to get a number from the user for the loops Calculate and print the sumTotal 5. Calculate and print the productTotal PART 2 6. Call GetInteger to get the length of the side of the square 7. Pass the length, "address of squarcArea, and "address of" squarePerimeter to the CalculateBothSquare function 8. Print the area and the perimeter onto the screen NOTE: The area and perimeter should be printed twice, once from inside the functions and then a second time in the main function (See sample output below) CalculateBothSquare function logie (and hints): Calculate the area and store the result in the value at" area Ptr Print the "value at" areaPtr onto the screen Calculate the perimeter and store the result in the "value at perimeterPtr Print the "value at" perimeterPtr onto the screen the function has a void return type

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

Students also viewed these Databases questions