Write a program to Input the values of three numbers and find out largest number by using logical AND operator(&&):
OR
Write a program to Input the values of three numbers and find out largest number by using multiple if statements:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
scanf("%d%d%d" ,&a,&b,&c);
if (a>b && a>c) // Both (a>b) and (a>c) must be TRUE to execute a is greater.
printf(" a is greater ");
if (b>a && b>c) // Both (b>a) and (b>c) must be TRUE to execute b is greater.
printf(" b is greater ");
if (c>b && c>a) // Both (c>b) and (c>a) must be TRUE to execute c is greater.
printf(" c is greater ");
getch();
} // End of main()
Output:
Enter the values of a,b and c:
34
65
24
b is greater
// This (b>a && b>c) condition is True So b is greater executed.
0 Response to "C Program: Find the Largest Number by using Logic AND(&&) Operator:"
Post a Comment