First of all helo to everyone. I'm new to this forum and I'm also new to C++. I'm in first year of university and we have programming lectures from C++. We had a test today and I couldn't design one simple program, and I still can't find out what I'm doing wrong.
So the task of the program is:
Design and implement a program that asks the user to enter a number and then guess at the square of the first number. If the user guesses correctly a congratulatory message is displayed, otherwise a commiseration message is displayed along with the correct answer.
This is how I tried to design a program:
C++ Code:
These are the errors: Line 16: 'if' undeclared(firs t use this function) (each undeclared identifier is reported only once for each function it appears in.) Thanks in advance.
So the task of the program is:
Design and implement a program that asks the user to enter a number and then guess at the square of the first number. If the user guesses correctly a congratulatory message is displayed, otherwise a commiseration message is displayed along with the correct answer.
This is how I tried to design a program:
C++ Code:
Code:
#include <iostream>
using namespace std;
int main ()
{
int number1;
int number2;
std::cout<<"Enter number to be squared: ";
std::cin>>number1;
std::cout<<"Guess the square: ";
std::cin>>number2;
If (number2==number1*number1);
std::cout<<"Good Guess"<<endl;
If (number2!=number1*number1);
std::cout<<"Not Correct."<<number1<<"squared is"<<number1*number1<<endl;
system("pause");
return 0;
}
Comment