write a program to input any three numbers and find the greatest number
Answers
Answered by
2
The program output is also shown below.* C program to find the biggest of three numbers.int num1, num2, num3;printf("Enter the values of num1, num2 and num3\n");scanf("%d %d %d", &num1, &num2, &num3);printf("num1 = %d\tnum2 = %d\tnum3 = %d\n", num1, num2, num3);if (num1 > num2)if (num1 > num3)
Answered by
3
import java.util.Scanner;
class LargestOfThreeNumbers
{
public static void main(String args[])
{
int x, y, z;
System.out.println("Enter three integers ");
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
z = in.nextInt();
if ( x > y && x > z )
System.out.println("First number is largest.");
else if ( y > x && y > z )
System.out.println("Second number is largest.");
else if ( z > x && z > y )
System.out.println("Third number is largest.");
else
System.out.println("Entered numbers are not distinct.");
}
}
class LargestOfThreeNumbers
{
public static void main(String args[])
{
int x, y, z;
System.out.println("Enter three integers ");
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
z = in.nextInt();
if ( x > y && x > z )
System.out.println("First number is largest.");
else if ( y > x && y > z )
System.out.println("Second number is largest.");
else if ( z > x && z > y )
System.out.println("Third number is largest.");
else
System.out.println("Entered numbers are not distinct.");
}
}
Similar questions
Social Sciences,
8 months ago
Math,
8 months ago
Art,
1 year ago
English,
1 year ago
English,
1 year ago