English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

A C++ program that will calculate the area and perimeter of a rectangle by using the function template template. The area and perimeter are calculated by using following formula:

area = length * width
perimeter = 2 *(length + width)

The program will read the values of length and width from the user trough keyboard and passes these values to the function calculate(T x, T y). The function calculates the area and perimeter of the rectangle and displays the result on the screen. The function returns no value.

2006-07-27 09:10:03 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

soundz lik a hw question ta mee :))

try this the function isnt goin to return a value so im assuing that the coutz are going to be in the function..im noo expert at this but o well watever

template
void functionname(T x, T y)
{
T area, perimeter;

area=x*y;
perimeter=2*(x+y);

cout<<"area: "<< area< cout<<"perimeter: "<< perimeter< }

now if u plz send ur checkz out to...hahahahahaha

2006-07-27 09:40:36 · answer #1 · answered by JAZ 2 · 0 0

look you need to learn the difference between the funtion and a sub-routine
a sub-routine never returns a value
while a function always retursn a value

just have a look at the program that
have you written something like void calculate (x,y) or something like that because then your function will not return anything
it will be as good as a sub - routine no return value

2006-07-27 16:15:30 · answer #2 · answered by akshay 2 · 0 0

//the program:

#include
#include
void Area(int tx , int ty)
{
int a;
a = tx * ty;
cout<<"The area is: "< }

void Per(int tx, int ty)
{
int p;
p = 2 * (tx+ty);
cout<<"The perimeter is "< }
int main()
{
int l,w;
cout<<" Write the Lenght and Width of a rectangle:"<<"/n";
cin< cin< Area(l,w);
Per(l,w);
return 0;
}

2006-07-27 16:21:15 · answer #3 · answered by hirbod_x 1 · 0 0

fedest.com, questions and answers