Problem statement:- Program to Find the Biggest of three numbers.
Example:
Input: 7 3 8
Output: 8
Input: -777 888 -7456
Output: 888
Data requirement:-
Input Data:-num1, num2, num3
Output Data:-max
Output Data:-max
Program in C
Here is the source code of the C Program to Find the Biggest of three numbers.
Code:
#include<stdio.h>
#include<limits.h>
int main()
{
int num1,num2,num3;
printf("Enter 3 numbers:");
scanf("%d %d %d",&num1,&num2,&num3);
int max=INT_MIN;
if(num1>max)
max=num1;
if(num2>max)
max=num2;
if(num3>max)
max=num3;
printf("The Biggest number is %d",max);
}
Input/Output:
Enter 3 numbers: -3 5 77
The Biggest number is 77
Program in C++
Here is the source code of the C++ Program to Find the Biggest of three numbers.
Code:
#include<iostream>
using namespace std;
int main()
{
int num1,num2,num3;
cout<<"Enter 3 numbers:";
cin>>num1>>num2>>num3;
int max=INT_MIN;
if(num1>max)
max=num1;
if(num2>max)
max=num2;
if(num3>max)
max=num3;
cout<<"The Biggest number is "<<max;
}
Enter 3 numbers:7 8 -44
The Biggest number is 8
Program in Java
Here is the source code of the Java Program to Find the Biggest of three numbers.
Code:
import java.util.Scanner;
public class BiggestNumber {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num1,num2,num3;
System.out.println("Enter 3 numbers:");
num1=cs.nextInt();
num2=cs.nextInt();
num3=cs.nextInt();
int max=Integer.MIN_VALUE;
if(num1>max)
max=num1;
if(num2>max)
max=num2;
if(num3>max)
max=num3;
System.out.println("The Biggest number is "+max);
cs.close();
}
}
Input/Output:
Enter 3 numbers:
77 -11 89
The Biggest number is 89
Program in Python
Here is the source code of the Python Program to Find the Biggest of three numbers.
Code:
print("Enter 3 numbers:")
num1=int(input())
num2=int(input())
num3=int(input())
print("The biggest number is ",max(num1,num2,num3))
num2=int(input())
num3=int(input())
print("The biggest number is ",max(num1,num2,num3))
Input/Output:
Enter 3 numbers:
888
-777
999
The biggest number is 999
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box