#include<iostream.h>
int function2.7(int a,int b)
{int i=1;int power=1;
power=power*a;
cout<<"power="<<power;
i+=i;
cout<<"i="<<i;
if(i<y)
cout<<"i is smaller than y";
else
cout<<"i is bigger than y";
return 0;}
void main()
{
//exercise 2.7
int x,y;
cout<<"input 2 numbers for x y:";
cin>>x>>y;
function2.7(x,y);
}
The code always gives error:
error C2143: syntax error : missing ';' before 'constant'
fatal error C1004: unexpected end of file found
Error executing cl.exe.
What compiler/IDE are you using? If it is old then #include<iostream.h> may not cause a problem, but if it is new than the include should be #include<iostream> (i.e. drop it .h) this would also mean that you would have to scope cout and such with std:: (i.e. std::cout << ... ) or use using namespace std; .
It also looks like line 8 should be if(i<b) and line 13 should be int main().
Sorry, forgot to mention that a return statement would be needed for int main. void main is not standard (but then again VC6 does not follow standards very much).
1 2 3 4 5
int main()
{
...
return 0;
}
Unless you have a pressing reason for using VC6, I would recommend getting an more up to date compiler/IDE.