Hi all, I am currently trying to create a code that will allow me to do the following:

Enter length vs. width of a rectangle

Receive area + perimeter values

I was given a solution template to get me started:

/* File rectangle.c

Given the dimensions of a rectangle in metres, compute its area and

perimeter length.

Programmer: Date:

*/

#include <stdio.h>

int main(void)

{

int x, y, area, perimeter;

printf("Dimensions of the rectangle (rounded to nearest metre): ");

/* you fill in the rest */

system("pause"); /* omit this line on Mac's */

return 0;

}

I cannot seem to figure this out with the given template, however I was able to create a code that allows me to get the area by entering l*w and all I would have to do from there was add another code which will allow the user to input 2 lengths and receive the perimeter. But I am worried my professor will expect me to use his template.

Here is MY version of the code which is half complete:

#include <iostream>

using namespace std;

int mult ( int l, int h );

int main()

{

int x, y, area, perimeter;

printf("Dimensions of the rectangle (rounded to the nearest metre) : ");

int l;

int h;

cout<<"Enter length, height: ";

cin>> l >> h;

cin.ignore();

cout<<"The area of your rectangle is "<< mult ( l, h ) <<"\n";

}

int mult ( int l, int h )

{

return l * h;

}

And here is the one I attempted off of his template:

/* File rectangle.c

Given the dimensions of a rectangle in metres, compute its area and

perimeter length.

Programmer: Date:

*/

#include <stdio.h>

int main(void)

{

int x, y, area, perimeter;

printf("Dimensions of the rectangle (rounded to nearest metre): ");

int mult ( int l, int h );

int main()

{

int x, y, area, perimeter;

printf("Dimensions of the rectangle (rounded to the nearest metre) : ");

int l;

int h;

cout<<"Enter length, height: ";

cin>> l >> h;

cin.ignore();

cout<<"The area of your rectangle is "<< mult ( l, h ) <<"\n";

}

int mult ( int l, int h )

{

return l * h;

}

I basically just migrated them. I have zero experience with C++, It's just a req in my first year of engineering. Any pointers will be greatly appreciated. Thanks!

system("pause"); /* omit this line on Mac's */

return 0;

}