I wrote this program to practice the if statement. I can't get it to execute the else statement. Regardless of what the user enters it executes the if statement.
//A program to let the user entera score and output if the score was perfect.
#include <iostream>
int main()
{
using namespace std;
cout << "Enter your programming class score" << endl << endl;
int x;
cin >> x;
if ( x = 100){
cout << "You got a perfect score!" << endl;
}
else{
cout << "It wasn't a perfect score" << endl;
}
system("pause");
Anyone know what I'm doing wrong?
Thanks.
//A program to let the user entera score and output if the score was perfect.
#include <iostream>
int main()
{
using namespace std;
cout << "Enter your programming class score" << endl << endl;
int x;
cin >> x;
if ( x = 100){
cout << "You got a perfect score!" << endl;
}
else{
cout << "It wasn't a perfect score" << endl;
}
system("pause");
Anyone know what I'm doing wrong?
Thanks.