expression must have (pointer-to-) function type

This seems to be a silly one for most of you. But please help me:

I am trying to get perimeter of rectangle and getting "expression must have (pointer-to-) function type" in perimeter function section for number 2:

#include <iostream>
using namespace std;
float area (float lg, float br) {
float a;
a = lg * br;
return a;

}

float perimeter (float lg, float br) {
float p;
p = (2(lg + br));
return p;
}

int main ()
{
float length, breadth, ar, pr;
cout << "Enter length & breadth of the rectangle: ";
cin >> length >> breadth;
ar = area(length, breadth);
pr = perimeter(length, breadth);
cout << "Area of rectangle is:" << ar << endl;
cout << "Perimeter of rectangle is:" << pr << endl;
system ("pause");
}
Instead of p = (2(lg+br));, maybe you meant p = 2*(lg+br);?
Last edited on
@cire: Thank you so much. That worked!!
Topic archived. No new replies allowed.