Program to find the largest of three numbers.

Here, we have a basic program example to print the largest number using different languages. This program is created in c language, c++, Java, and Python.

Program to print the largest number in C language

#include <stdio.h>
void main()
{
    int num1, num2, num3;

    printf("Enter First number: ");
    scanf("%d", &num1);
    printf("Enter Second number: ");
    scanf("%d", &num2);
    printf("Enter Third number: ");
    scanf("%d", &num3);
    if (num1 >= num2 && num1 >= num3)
        printf("%d is the largest number",num1);
    else if(num2 >= num1 && num2 >= num3)
        printf("%d is the largest number",num2);
    else if(num3 >= num1 && num3 >= num2)
        printf("%d is the largest number",num3);
    return 0;
}

Program to print the largest number in C++ language

#include<iostream>
using namespace std;
int main(){
int num1, num2, num3;

    cout<<"Enter First number: ";
    cin>>num1;
    cout<<"Enter Second number: ";
    cin>>num2;
    cout<<"Enter Third number: ";
    scanf("%d", &num3);
    if (num1 >= num2 && num1 >= num3)
        cout<<num1<<" is the largest number";
    else if(num2 >= num1 && num2 >= num3)
        cout<<num2<<" is the largest number";
    else if(num3 >= num1 && num3 >= num2)
        cout<<num3<<" is the largest number";
    return 0;
}

Program to print the largest number in Python language

num1 = int(input(“Enter first number:  “))

num2 = int(input(“Enter second number:  “))

num3 = int(input(“Enter third number:  “))

if num1 >= num2 and num >= num3 :

    print(num1,”is the larget number\n”)

elif num2 >= num1 and num2 >= num3:

    print(num2,”is the larget number\n”)

elif num3 >= num1 and num3 >= num2:

    print(num3,”is the larget number\n”)

Program to print the largest number in Java language

import java.util.*;
class largest
 {
   public static void main(String[] args)
    {
      int num1, num2, num3;
  
      Scanner s=new Scanner(System.in);
      System.out.println("Enter first number :");
      num1 = s.nextInt();
      System.out.println("Enter second number :");
      num2 = s.nextInt();
      System.out.println("Enter third number :");
      num3 = s.nextInt();
     if(num1 >= num2 && num1 >= num3){
       System.out.println(num1+" is the largest number");
          }
     else if(num2 >= num1 && num2 >= num3) {
       System.out.println(num2+" is the largest number");     
          }
     else if(num3 >= num1 && num3 >= num2) {
       System.out.println(num3+" is the largest number");     
          }
}
}