0
Help please
Input two variables A B and put them on screen which is bigger.C++
8 Respostas
+ 1
The answer will be in python
X=input=("plz enter the first number")
Y=input("plz enter the second number")
if X > Y :
print("X is bigger than Y")
elif X< Y :
print("Y is bigger than X")
elif X == Y :
print("X equal to Y")
else :
print("error")
The answer in C++
int x,y;
cout<<"plz enter the first number";
x=cin>>;
cout<<"plz enter the second number";
y=cin>>;
if( x > y)
cout<<"x is greater than y" ;
elseif( x < y)
cout<< "y is greater than x" ;
elseif (x==y)
ckut<<"x equal to y" ;
else
cout<<"error";
0
Declare your variables they must be of type integer.Then get user input with cin>> method .then compare them using > making condition so then cout the greatest one.
0
can you write the code?
0
I just don't know anything about C++ for the first time
0
How?
0
Oh thanks bro❤✊
- 1
//C++ source code
#include <iostream>
using namespace std;
int main() {
int a,b; //declaring variables
cin>>a; //taking the value of a
cin>>b; //taking the value of b
if(a>b) //checking the number, which one is greater
cout<<a; //showing a ,if a is greater
else
cout<<b; //showing b if b is greater
return 0;
}
// :)