equality operators

I am working on my programming and increasing gradually in complexity. Thanks in advance for your help.

Please EXPLAIN don't give me the code or answer but....
please tell me when I run this program it says build was successful but it does give me the option to enter integers using the cin.....
//Write a program that asks the user to enter two integers,
//obtains the number from the user, then prints the larger number followed
//by the words "is larger. " If the numbers are equal, print the mesage "These numbers are equal."

#include <iostream>
using namespace std;

int main()
{

int a;
int b;

cin>>a;
cout<<"Enter first integer:"<<a;

cin>>b;
cout<<"Enter your second integer:"<<b;

if(a==b) cout << "these numbers are equal";
if(a>b) cout << "is larger";


}



what am I missing and why? where is my logic failing me?
1
2
3
4
// first read a value into a
cin>>a;  
// then print "Enter first integer", then print the value stored in a
cout<<"Enter first integer:"<<a;  


Probably you want to prompt the user before reading a value:
1
2
cout<<"Enter first integer:";  
cin>>a;
Last edited on
Thank you very much.
Topic archived. No new replies allowed.