Greetings!
My name is Andrew and I am in the 9th grade and I started programming in c++.
I have to do a program which tells if a given number is, or not a perfect square.
#include<iostream.h>
#include<math.h>
int n,a;
int main()
{
cin>>n;
if (n=a*a);
cout<<"n este patrat perfect";
else
cout<<"n nu este patrat perfect";
return 0;
}
This is what i've done and it seems that i've got a "syntax error before else".
If someone could point out where I am wrong I would be very happy.
Thank you in advance.
P.S. I would like the one who is reading this to excuse my poor english. I live in Romania, which is not an english speaking language.
1
Expert's answer
2012-10-19T12:04:08-0400
Here is corrected code:
#include <iostream.h> #include <math.h> int n,a; int main() { cin>>n; if (n=a*a) & cout<<"n este patrat perfect"; else & cout<<"n nu este patrat perfect"; return 0; }
Comments
Leave a comment