This first assignment I didnt have any problems with. The following assignment that is linked to this first assignment is the one i could use some help with.

Create a small program based on the following

(calculate area of a circle and a rectangle):

//use integers for the length, width, areaR, and radius,

//use double for areaC

1. Declare variables: length, width, areaR, radius, and areaC.

2. Ask the user to enter the length and width of the rectangle and the radius of the circle.

3. Get the length, width, and radius from the user.

4. Calculate the area of the rectangle.

5. Display the length, width, and area of the rectangle onto the screen.

6. Calculate the area of the circle (use 3.14).

7. Display the radius and area of the circle onto the screen.

#Code:include<stdio.h>; //defines PI at 3.14 #define PI 3.14 int main(void){ // five declared variables int length = 0; int width = 0; int areaR = 0; int radius = 0; double areaC = 0.0; //Ask the user the length and width of the rectangle printf("Please enter the legnth and width of the rectangle: \n"); //Get the length and width from the user scanf("%d%d", &length, &width); //Calculate the area of the rectangle areaR = length * width; //Print the area of the rectangle printf("Area of the rectangle is: %d\n", areaR); //Ask the useer for the radius of the circle printf("Please enter the radius of the circle: \n"); //Get the radius of the circle scanf("%d", &radius); //Calculate and are of the circle areaC = PI * radius * radius; //Print the area of the circle printf("The area of the circle is: %lf\n", areaC); // %lf is for double return 0; }

This is the assignment I need some help with.

I have attached what i have written so far for this second assignment and am not sure what steps to take next, or if i have written it properly so far.

Break up the program (areas) from last week into one main function and 4 user-defined functions:

// gets an integer from the user and returns it

// make 3 calls to this function:

// get the length of the rectangle from the user and return it to main

// get the width of the rectangle from the user and return it to main

// get the radius of the circle from the user and return it to main

int GetNum(void);

// takes two arguments, the length and width of the rectangle and returns the area

int CalculateAreaR(int length, int width);

// takes one argument, the radius of the circle and returns the area

double CalculateAreaC(int radius);

Code:#include <stdio.h> #define PI 3.14 int GetNum(void); int CalculateAreaR (int length, int width); double CalculateAreaC(int radius); int main() { int length; int width; double radius; printf( "Please enter the length of the rectangle: \n"); scanf("%d", &length); printf( "Please enter the width of the rectangle: \n"); scanf("%d", &width); printf("The area of the rectangle is %d\n", CalculateAreaR(length, width)); getchar(); printf("PLease enter the radius of the circle: \n"); scanf("%lf", &radius); printf("The area of the circle is %lf\n", CalculateAreaC(radius)); getchar(); } int CalculateAreaR (int length, int width){ return length * width; } double CalculateAreaC(int radius){ return PI * radius * radius; }