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.

+2 votes
asked Aug 9, 2019 by anonymous

20 Answers

0 votes
answered Aug 18, 2019 by Ravi Pancharia (210 points)
#include<iostream>
using namespace std;
int main()
{int n,m;
cout<<"enter the value of n=";
cin>>n;
cout<<"enter the value of m=";
cin>>m;
if(m>n)
cout<<"m is greater then n";
}

//comment=
enter the value of n=2                                                                                                         
enter the value of m=3                                                                                                         
m is greater then n
0 votes
answered Aug 19, 2019 by Raghul
#include <stdio.h>

int main()
{
    int x,y,z;
    printf("Enter the value of x and y\n");
    scanf("%d %d",&x,&y);
    
    z = (x>y) ? x:y;
    printf("%d",z);
    return 0;
}
0 votes
answered Aug 20, 2019 by rv singh
x=int(input("enter the fitrst no"))

y=int(input("enter thye second no"))

if(x>y):

print("x is greater")

else:

print("y is greater")
0 votes
answered Aug 20, 2019 by Sivani
#include <stdio.h>
 int main()
    {
    int x,y;
    x=2;
    y=5;
    if(x>y)
     {
       printf("x is maximum");
     }
    else
      {
        printf("y is maximum");
       }
     }
0 votes
answered Aug 21, 2019 by bhoomi2000 (780 points)

#include<stdio.h>

#include<conio.h>

void main()

{

       int a,b;

       â€‹scanf("%d%d",&a,&b);

       if (a>b)

       printf("max is: %d\n",a);

       if (a<b);

       printf("max is: %d\n",b);

       getch();

}

0 votes
answered Aug 21, 2019 by anonymous
x=int(onput())

y=int(input())

if x>y::

print (x)

else:

print(y)
0 votes
answered Aug 21, 2019 by noobie
x=int(input("enter first num: "))

y=int(input("enter second num:"))

z=max(x,y)

print("large :",z)
0 votes
answered Aug 22, 2019 by Suhas Gowda
//java program
class main
{
public static void main(String args[])
{
int x=Integer.parseInt(args[0]);
int y=Integer.parseInt(args[1]);
int m=Math.max(x,y);
System.out.println(""+m);
}
}
0 votes
answered Jan 29, 2025 by Bha (140 points)
import java.util.*;
public class lve{
    public static void main(String[]args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("Enterintthe number of elements:"); 
        n=sc.nextInt();
        int []arr=new int[n];
        System.out.println("Enter the elements:");
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        int max=arr[0];
        for(int i=1;i<n;i++){
            if(arr[i]>max){
                max=arr[i];
            }
        }
        System.out.println("largest elements"+max);
            }
        }
  

0 votes
answered Feb 2, 2025 by Abdullah Shafi (340 points)
#include <stdio.h>

int main()

{

float x, y ;

printf("Type the value of x, y") ;

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

if(x>y) {

printf("%f", &x) ;

}

else {

printf("%f", &y) ;

}

return 0 ;

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...