help me fix my code please

its telling me it has errors but i dont know how to fix it

#include <iostream>
#include <cmath>

using namespace std;
int main ()
{
int a,b,choice;
int sqr(int a);
int sqrRoot(int a);
double result;
while(true)
{
cout<<"enter a number"<<endl;
cin>>a;
cout<<"whould you like to see the (1) square, (2) square root, (3) is the number odd or even or (4) exit"<<endl;
cin>>choice;
if(choice==4)
switch(choice)
{
case 1:
result=sqr(a);
cout<<"the square of "<<a<<" is "<<b<<endl;
cout<<endl;
break;
case 2:
result=sqrRoot(a);
cout<<"The square root of "<<a<<" is "<<b<<endl;
break;
case 3:
if ( a % 2== 0 )

cout << a << " is even "
<<endl;
else
cout << a << " is odd "
<<endl;

}
}

system ("pause");

return 0;

}


int sqr(int a)
{
int b;
b=a^2;
return b;
}


int sqrRoot(double a)
{
double b;
b=sqrt(a);
return b;
}
1. Edit your post and put [code] before your code and [/code] after your code - this allows for syntax highlighting and doesn't remove indentation.

2. Copy and paste your exact error messages so we know what you're dealing with.
first in your int sqrRoot(int a);
isnt it double? double a
second it's not even made well
Instead of bitching about format or knowledge-level, do it yourself or don't say anything

EDIT: Didn't follow solution rule. Removed it. Sorry.
Last edited on
@sherre02: it is against this community's agreed-upon rules to post full solutions to questions of this nature. We're here to help people learn, not to hand out free solutions.
Topic archived. No new replies allowed.