write a program to input any three numbers and print the greatest number among them.
Answers
Answer:
Example 1: Using if Statement
Example 1: Using if Statement#include <stdio.h> int main() { double n1, n2, n3; printf("Enter three different numbers: "); scanf("%lf %lf %lf", &n1, &n2, &n3); // if n1 is greater than both n2 and n3, n1 is the largest if (n1 >= n2 && n1 >= n3) printf("%.2f is the largest number.", n1); // if n2 is greater than both n1 and n3, n2 is the largest if (n2 >= n1 && n2 >= n3) printf("%.2f is the largest number.", n2); // if n3 is greater than both n1 and n2, n3 is the largest if (n3 >= n1 && n3 >= n2) printf("%.2f is the largest number.", n3); return 0; }
Answer:
//program to print the highest among three no.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf(“ enter the three no.”);
scanf(“%d%d%d",&a,&b,&c);
if( a>b)
{
if(a>c)
{
printf( “ a is the highest");
}
}
else if(b>a)
{
if(b>c)
{
printf( “ b is the highest");
}
}
else
{
printf( “ c is the highest");
}
}
You may get confused by the bracket but try to write this as it is .
Explanation:
plz mark as brainliest and follow me.