write a program to find the greatest of three numbers using nested if
Answers
Answered by
1
Question:-
Write a program in c to find greatest among three integers.
Solution:-
// Program to find largest among three numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
clrscr();
printf("Enter three integers");
scanf("%d%d%d",&a, &b, &c);
if (a>b && a>c)
{
printf("%d is the largest number",a);
}
elseif (b>c)
{
printf("%d is the largest number",b);
}
else
{
printf("%d is the largest number",c);
}
getch();
}
Answered by
0
Here's a program in Python to find the greatest of three numbers using nested if statements:
- def find_greatest(num1, num2, num3):
- if num1 >= num2:
- if num1 >= num3:
- return num1
- else:
- return num3
- else:
- if num2 >= num3:
- return num2
- else:
- return num3
- num1 = int(input("Enter the first number: "))
- num2 = int(input("Enter the second number: "))
- num3 = int(input("Enter the third number: "))
- greatest = find_greatest(num1, num2, num3)
- print("The greatest number is: ", greatest)
#SPJ3
Similar questions