code error

can any one plz help me to know about the error in this code...
#include<iostream>
#include<cmath>
using namespace std;

float imag,real,disc;
main()
{
void QE();
float a,b,c,disc1,disc2;
cout<<"enter ist number";
cin>>a;
cout<<"enter second number";
cin>>b;
cout<<"enter third number";
cin>>c;

disc1=(b*b);
disc2=(4*a*c);
disc=disc1-disc2;
real=((b*b)/(2*a));
imag= ( sqrt ((b*b)-(4*a*c)/(2a));
QE();
return 0;
}
QE()
{if(disc<0)
cout<<"imaginary is"<<"+i"<<imag;
cout<<"imaginary is"<<"-i"<<imag;
if(disc>0)
cout<<"roots is"<<real;
if(disc==0)
cout<<"roots is equal";
return 0;
}
a function is declared "return-type name ( arguments-if-any-)"
your functions lack return types.

you cannot declare QE inside main. local function declarations are not in the standerd. and even if they were, you'd still be doing it wrong.

you declared QE as void, but it returns 0. void functions can't return something;. they may however return; if needed.
you cannot declare QE inside main. local function declarations are not in the standerd. and even if they were, you'd still be doing it wrong.
There's nothing wrong with function declaration inside other functions
in both cases my prog still gives 2 errror ...plz help
[code] "Your code goes here" [/code]
Could you be a little more specific about the errors?
these both errors are in imag line

error C2059: syntax error : 'bad suffix on number'
error C2146: syntax error : missing ')' before identifier 'a'
i tried to resolve them by diff ways but failed even by changing the brackets around b2-4ac...etc
There's nothing wrong with function declaration inside other functions
you live and learn..
Last edited on
'bad suffix on number' ' missing ')' before identifier 'a'
imag= ( sqrt ((b*b)-(4*a*c)/(2a));
what the error here???
You screwed up your parenthesis in assigning imag.
can any one correct it plz
Topic archived. No new replies allowed.