How to take space seperated integers in c++

1 Like
int x,y;
cin>>x>>y;
1 Like

bro !!space separated… its not working

That’s how you take space sperated inputs, show me the code if it’s not working

2 Likes

two spaces are given by the user
#include <bits/stdc++.h>
using namespace std;

int main()
{
//write your code here
int a,b;
cin>>a>>b;
if(a==b)
{
cout<<a<<“is equal to”<<b;
}
if(a>b)
{
cout<<a<<" is greater than “<<b;
}
else
{
cout<<a<<” is smaller than "<<b;
}
return 0;
}

two space separated integers are been given by the use

It should be working… looks correct, what error are u getting?

1 Like


i am unable to get it

Not sure how strict the checker is, but you’re missing a space after the is equal to.

3 Likes

thanks for your time it is completed …the error is in the printing way

2 Likes


is there any mistake i my code…