60 617
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #16690 in C++ for Andrew

Question #16690
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.
Expert's answer
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions