GREATEST OF THREE NUMBERS USING C PROGRAM!!!
|TO CHECK THE GREATEST NUMBER|
In this program, we going to get three numbers (a,b,c) in these three numbers we going to check which is greater.
- Let’s start the program with the header file
“#include<stdio.h> →*The C programming language provides many standard library functions for file input and output. These functions make up the bulk of the C standard library header <stdio. h>. ... The file is called a header file and you will find several different header files on the source disks that came with your C compiler.
#include<conio.h>the use of #include conio h in C++? #include a preprocessor directive, used to paste the code of the given file to the current file. conio. h is a non-standard header file, used mostly by MS-Dos compilers like turbo c/c++ to provide console input/output.
void main() →main function will not return any value”
- Then in the main program, we give a clear screen.
“{
int a,b,c;
clrscr();
printf(“ENTER THREE DIFFERENT NUMBERS:\n”);
scanf(“%d%d%d”,&a,&b,&c);”
- Now we are declaring three-variable (a,b,c) in integer; then we are giving printf statement, inside prinf statement we given “ENTER THREE DIFFERENT NUMBERS.
- Next in sacnf we have given three “%d” because we are giving three values.
printf →it is used to display output.
scanf →it is used to take input from the user
%d →a decimal integer
& →is a address operator means it tells the compiler that the integer value that you are giving or passing in the program is stored in which place or in which variable.
- Now we going to compare the variable (a,b,c) using “if statement”
IF STATEMENT:
The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false. … One of the important functions of the if statement is that it allows the program to select an action based upon the user’s input.
“ if(a>b&&a>c)
printf(“%d is the largest number”,a);”
- First, we going to check whether “ a” greater than “b and c”; if this statement becomes true it will print the number given in a is the largest number.
“if(b>a&&b>c)
printf(“%d is the largest number”,b);”
- Now we will check whether “b” is greater than “a and c”; if this statement becomes true, it will print the number given in b is the largest number.
“ if(c>a&&c>b)
printf(“%d is the largest number”,c);”
→same as above
“ getch();
return 0;
}”
getch() →getch() is a way to get a user inputted character. It can be used to hold program execution, but the “holding” is simply a side-effect of its primary purpose, which is to wait until the user enters a character.
SOURCE CODE:
OUTPUT:
REFERENCE LINK:
To know more about the c program, log in “GUVI”