i have no idea why my program isnt working

im getting the error messages "error: expected ';' before ')' token
and error: expression cannot be used as a funtion

any help at all is much appreciated

//This program will calculate both the area and perimeter of this shape

#include <fstream>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main ()
{

double a,b,c,d,e,f,g,g1,h,i,j,pi,area_51,per;
a=10;
b=3;
c=6;
f=4;
g=5;
g1=4.3;
g2=2.5;
h=3.5;
j=11;
pi=acos(-1);

ofstream output ("E:result.dat");
output<<"the perimeter of the shape is"<<per<<endl;
cout<<"the area of the shape is"<<area_51<<endl;
output<<"the area of the shape is"<<area_51<<endl;

per=(2*pi*pow(a,2.0)+pow(b,2.0),.5)/2)+(pi*(c*.5)/2)+(pow(g,2.0)+pow(f,2.0))+f+(2*(a+))+j;
area_51=((pi*a*b)/2)+(pi*b/2)+((g*b*2/2)/2)+(h*a)(a*j);

cout<<"the perimeter of the shape is"<<per<<endl;
output<<"the perimeter of the shape is"<<per<<endl;
cout<<"the area of the shape is"<<area_51<<endl;
output<<"the area of the shape is"<<area_51<<endl;
system ("pause");
return 0;

}
Last edited on
Hey. Please Use codetags for all of your code, so it is easier to read - http://www.cplusplus.com/articles/jEywvCM9/

You have a few problems.First one:

This is what yours look like:
per=(2*pi*pow(a,2.0)+pow(b,2.0),.5)/2)+(pi*(c*.5)/2)+(pow(g,2.0)+pow(f,2.0))+f+(2*(a+))+j;

You are missing an opening ( at the very beginning. (2*pi should be ((2*pi

Also - (a+)), a + what? You are missing a variable/number here.

Second Problem:

area_51=((pi*a*b)/2)+(pi*b/2)+((g*b*2/2)/2)+(h*a)(a*j);

This part specifically: (h*a)(a*j) You are missing an operator between the two.
should it be (h*a) + (a*j) or (h*a) * (a*j)

Third Problem:

"per" is never initialized. And the first thing you do is - output<<"the perimeter of the shape is"<<per<<endl; per has no value, it is garbage. You calculate per after that. Wouldnt you first want to calculate per, and then put it in the file?
Last edited on
thank you for the help!
Topic archived. No new replies allowed.