How do you get the var's to move from main to a module, return that data and pass it on to the next module?
This is the code that i have come up with so far, I am attempting to make a program that calculates the area and perimeter of a rectangle.
#include <stdio.h>
//prototypes
void main();
void getUserInput();
void calculateArea();
void calculatePerimeter();
void outputToScreen();
////////////////////////////
void main(void)
{
int perimeter=0;
int length=0;
int width=0;
int area=0;
printf ("This program was created by John Low\n");
printf ("Please enter the width: ");
getUserInput();
//return 0;
} // end of main
void getUserInput(void)
{
scanf("%d", &width);
printf("Enter the length: \n");
scanf("%d", &lenght);
} // end of getUserInput
/*
void calculateArea(void)
{ &width * &length = area;
} // end of calculateArea
void calculatePerimeter(void)
{ &width * 2 + &length * 2= perimeter;
} // end of calculate Perimeter
void outputToScreen(void)
{ printf ("The area is: \n")
printf ("The perimeter is: \n")
}*/ // end of outputToScreen
I have nulled out the last little bit, because I was having difficulty getting the first module to work as it should.
This is the code that i have come up with so far, I am attempting to make a program that calculates the area and perimeter of a rectangle.
#include <stdio.h>
//prototypes
void main();
void getUserInput();
void calculateArea();
void calculatePerimeter();
void outputToScreen();
////////////////////////////
void main(void)
{
int perimeter=0;
int length=0;
int width=0;
int area=0;
printf ("This program was created by John Low\n");
printf ("Please enter the width: ");
getUserInput();
//return 0;
} // end of main
void getUserInput(void)
{
scanf("%d", &width);
printf("Enter the length: \n");
scanf("%d", &lenght);
} // end of getUserInput
/*
void calculateArea(void)
{ &width * &length = area;
} // end of calculateArea
void calculatePerimeter(void)
{ &width * 2 + &length * 2= perimeter;
} // end of calculate Perimeter
void outputToScreen(void)
{ printf ("The area is: \n")
printf ("The perimeter is: \n")
}*/ // end of outputToScreen
I have nulled out the last little bit, because I was having difficulty getting the first module to work as it should.