Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Saturday, July 16, 2022

C Program to Find the Greatest Number Among Input Three Numbers

 C Program to Find the Greatest Number Among Input Three Numbers


Using “if” statement

#include<stdio.h>

#include<conio.h>

main()

{

int a,b,c;

printf("Enter three numbers\n");

scanf("%d %d %d",&a, &b, &c);

if( a>b && a>c)

printf("a is greatest and the number is %d",a);

if(b>c && b>a)

printf("b is greatest and the number is %d",b);

if(c>a && c>b)

printf(" c is greatest and the number is %d",c);

getch();

}

 

Using if…else if statement

#include<stdio.h>

#include<conio.h>

main()

{

int a,b,c;

printf("Enter three numbers\n");

scanf("%d %d %d",&a, &b, &c);

if( a>b && a>c)

printf("a is greatest and the number is %d",a);

else if(b>c)

printf("b is greatest and the number is %d",b);

else

printf(" c is greatest and the number is %d",c);

getch();

}


Output:



No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages