Visual Studio 2010 Error

Getting Error: Expression must have a (pointer-to-) function type. Its in the last function.

#include <iostream>
#include <fstream>
using namespace std;

void ProcessEdges();
bool isValid();
double area();

int main()
{
void ProcessEdges();
double area();
bool isValid();

system("pause");
return 0;
}

void ProcessEdges(ifstream& in_stream, ofstream& out_stream)
{
ifstream in_stream;
ofstream out_stream;

in_stream.open("edges.txt");
out_stream.open("area.txt");

int a, b, c;
in_stream >> a >> b >> c;

in_stream.close();
out_stream.close();
}

bool isValid(int a,int b,int c)
{
double sum;
sum = a + b;
if(sum>=c)
{
cout << sum << endl;
}
else if (sum<c)
{
cout << "*" << endl;
}
return 0;
}

double area(int a, int b, int c)
{
double sarea;
int s = ((a+b+c)/2);

sarea = sqrt ((s(s-a)(s-b)(s-c))); //Error is where the first 's' is
return sarea;
}


I need a little help. Im not done with my assignment. Just want to know how to fix this error.
Last edited on
I think your error comes from line 6. You need to have a decleration that's identical to the first line of your definition (except your decleration must end with a semi-colon -- which you did).

So line 6 I think should be:

double area(int a, int b, int c);//don't forget the semi-colon if you're copy-pasting from the function definition

Two more points. In the future when you post your code, press the "<>" button next to the box where you write your posts. This will make your code appear nice and tidy like this.Secondly this line is going to give you trouble:

int s = ((a+b+c)/2);

To illustrate this point, take the following example:

1
2
3
4
5
6
short a, b, c;
a=1;
b=2;
c=4;

cout << ((a+b+c)/2);//this line will display THREE (3) not 3.5 because you're using integers 


To have the above line work correctly, one or more of the numbers on line 6 to the right of the "=" symbol in the above code have to be of the type double -- so either define a, b, and/or c as type "double" or divide by "2.0" as opposed to "2" (the first is a double and the latter is an integer).

Either will work:

1
2
3
4
5
6
double a, b, c;//a b and c are DOUBLEs
a=1;
b=2;
c=4;

cout << ((a+b+c)/2);


1
2
3
4
5
6
short a, b, c;
a=1;
b=2;
c=4;

cout << ((a+b+c)/2.0);//using 2.0 instead of 2 




Good luck.
when i put the semi colon after the c); i get another error at the first bracket.

expecting a declaration
Topic archived. No new replies allowed.