C program: Find the greatest of three Numbers. This sample simple program discuss about finding largest value from the given few numbers by the C source code. It is a simple source program to understand easily. It can be used in all LAB exams and theory exams also. It is an useful C program for beginners.
[Related: Learn English Quickly] & [Love % Calculator]
GREATEST OF THREE NUMBERS IN C
Greatest of three numbers in C is used find the biggest of 3 numbers in an entered value by using conditional statement (nested if… else if). First check the outer if statement, condition is correct go for inner if…else if statement, else it will go to else if statement or otherwise check inner if. If it is true it will give the present value or else were.
C PROGRAM:
/* Title: Greatest Numbers Author: Vinoth © http://students3k.com This website provides lots of useful information for all students. */ //Header files #include<stdio.h> #include<conio.h> void main() { //Program variables float value1,value2,value3; clrscr();//Function is used to clear the previous output printf("\n\n FIND GREATEST OF THREE NUMBERS"); //display function printf("\n\n ENTER THE THREE VALUES TO COMPARE\t"); scanf("%f%f%f",&value1,&value2,&value3); //getting value function if(value1>value2) //Nested if…else statement(conditional statement) { if(value1>value3) { printf("Greatest Number Is %f",value1); } else if(value3>value2) { printf("Greatest Number Is %f",value3); } } else if(value2>value3) { printf("Greatest Number Is %f",value2); } else if(value3>value1) { printf("Greatest Number Is %f",value3); } getch(); }