when i type 8 and 22 or anything
it wont comes up and disappear
am i type something wrong?
i suppose to have if it is 8 and 22 or 8 and 8
will come up 8 > 22 , 8 == 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream>
usingnamespace std;
int main(){
int number1;
int number2;
cout << "Enter two integers to compare: ";
cin >> number1 >> number2;
if (number1 == number2)
cout << number1 << " == " << number2 << endl;
if (number1 > number2)
cout << number1 << " > " << number2 << endl;
return 0;
}
even i type another cases still not work but my friend type as the same thing and he work , he doesn't need another cases at all.
my homework is to write a program that asks the user to enter two integers , obtains the numbers from the user , then prints the larger number followed by the words "is larger."if the numbers are equal, print the message "these numbers are equal."
#include<iostream>
usingnamespace std;
int main(){
int number1;
int number2;
cout << "Enter two integers to compare: ";
cin >> number1 >> number2;
if (number1 == number2)
cout << number1 << " == " << number2 << endl;
if (number1 > number2)
cout << number1 << " > " << number2 << endl;
else
cout << "Phone a friend\n";
return 0;
}
Enter two integers to compare: 2
2
2 == 2
Phone a friend
Also I don't think it is a good idea to have cin >> .. >> ..
It's better to have two separate cout prompts and two separate cin's, one after each prompt. That way you get some feedback instead of a blank screen until you get the input right.