Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Write a program to enter the value of two variables (X and Y). Find and print themaximum value for two variables.

0 votes
asked Aug 9, 2019 by anonymous

18 Answers

–1 vote
answered Aug 10, 2019 by anonymous
a = input().split(' ')
print(max(int(a[0]),int(a[1])))
–1 vote
answered Aug 10, 2019 by anonymous
x=23

y=55

ifx>y:

print(x)

else:

print(y)
commented Aug 20, 2019 by SWengineer
There is no standard print() function in C++. There is printf() from C, though.
–1 vote
answered Aug 11, 2019 by Abhinandan Jain (120 points)
#include <stdio.h>

int main()
{
    int a,b;
    printf("enter your number ");
    scanf("%d%d",&a,&b);
    if (a>b)
    {
        printf("%d is greater ",a);
    }
    else
    {
        printf("%d is greater",b);
    }
    
    

    return 0;
}
–1 vote
answered Aug 11, 2019 by Lucifer
#include<stdio.h>
void main()
{
   int a,b;
    printf("Enter the two numbers:");
    scanf("%d,%d",&a,&b);
    if(a>b)printf("%d",a);
    else if(a<b)printf("%d",b);
    else printf("The two numbers are equal");
}
+1 vote
answered Aug 14, 2019 by yuvraj (300 points)
#include <stdio.h>

int main()
{
    int a,b;
    printf("enter your number ");
    scanf("%d%d",&a,&b);
    if (a>b)
    {
        printf("%d is greater ",a);
    }
    else
    {
        printf("%d is greater",b);
    }
     return 1;
}
+1 vote
answered Aug 14, 2019 by Deep Dhakad (160 points)
#include<iostream>

using namespace std;

int main()

{

  int x,y;

cin>>x>>y;

cout<<max(x,y)<<endl;

return 0;

}
+1 vote
answered Aug 14, 2019 by anonymous
x = int(input())

y = int(input())

if x>y:

    print(x)

else:

    print(y)
0 votes
answered Aug 15, 2019 by Vasilij (140 points)
int a = 1, b = 5;
printf("Max = %d", a>b?a:b);
0 votes
answered Aug 16, 2019 by Ishika Jain
#include<stdio.h>

int main()

{

int x , y , z;

scanf("%d %d",&x,&y);

z = x>y?x:y;

printf("%d",z);

return 0;

}
0 votes
answered Aug 18, 2019 by anonymous
x=int(input("enter the number")

y=int(input("enter the number")

if(x>y):

print("greater value is",x)

else:

print("greater is",y)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...