Home Basic Loop Array string Function Pointer Contact STUDY

# AHF    C    PROGRAM    SOLVING

### Find large number of two or three given numbers

```
// AHF C PROGRAM SOLVING

//solving here basic type of programming problem
We can implement this code in three different ways
The first way is below:
#include<stdio.h>
#include<math.h>
#define pf printf

int main()
{
int a,b,c;

pf("\nEnter any three number: ");
scanf("%d %d %d",&a,&b,&c);

if(a>b && a>c)
pf("\n%d is grater than %d and %d",a,c,b);
if(b>a && b>c)
pf("\n%d is grater than %d and %d",b,c,a);
else
pf("\n%d is grater than %d and %d",c,a,b);

return 0;
}

The second way is below:
#include<stdio.h>
#include<math.h>
#define pf printf

int main()
{
int a,b,c;

pf("Enter three number: ");
scanf("%d %d %d",&a,&b,&c);

if(a>b)
{
if(a>c)
pf("\n%d is grater than %d and %d",a,c,b);
else
pf("\n%d is grater than %d and %d",c,a,b);
}
else if(b>c)
pf("\n%d is grater than %d and %d",b,c,a);
else
pf("\n%d is grater than %d and %d",c,b,a);

return 0;
}

The third way is below:
#include<stdio.h>
#include<math.h>
#define pf printf

int main()
{
int number1,number2,number3,large;

pf("\nEnter the first number: ");
scanf("%d",&number1);

pf("\nEnter the second number: ");
scanf("%d",&number2);

pf("\nEnter the third number: ");
scanf("%d",&number3);

large=number1>number2?(number1>number3?number1:number3):(number2>number3?number2:number3);

pf("\n%d is the largest number",large);

return(0);
}

This program is used two variable.
#include<stdio.h>
#include<math.h>
#define pf printf

int main()
{
int a,b,large;

pf("Enter the first number: ");
scanf("%d",&a);

pf("\nEnter the second number: ");
scanf("%d",&b);

large=a>b?a:b;

pf("\n%d is the large number",large);

return (0);
}

```
OUTPUT:

## User may also visit:

© 2018 - All rights reserved