Hello I'm new to c++ i need help with a area and perimeter function. I can get the program to run fine with out using it as function but cant with trying to get it to run as a function.
Here is my code:

#include <iostream>   
using namespace std;  
int main() 
 int width; 
 int length;  
 int area; 
 int perimeter;       
 cout << " Please enter the width and length of a rectangle " << endl; 
 cin >> width >> length;   
 area= width*length; 
 perimeter= 2*(width+length);      
 cout << " The area is " << area << endl; 
 cout << " The perimeter is" << perimeter << endl;        
 return 0;


but question is how can i get the area and perimeter to work as a function any help would be very much appreciated thank you.

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

8 Years
Discussion Span
Last Post by Fbody

First thing is you have to try to make it a function. Then describe the problem you are having with it. We can then offer suggestions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.