In: Computer Science
Must be done in C
Write a C program found out the maximum value between the three numbers?
Show steps with comments or else it will be flagged.
#include<stdio.h> //header file
#include<conio.h> //header file should be used when clrscr(clear screen ) and getch(get character) is used in program.
void main() //main function
{
int a,b,c; //inputs here are a,b,c
clrscr(); //clears the previous outputs
printf("Enter the value of three numbers"); //inputs here are a,b,c
scanf("%d%d%d",&a,&b,&c);
//takes in, the given inputs
if(a>b&&a>c)
//condition is true when a is greater than both b and c
{
printf("The maximum value is %d",a);
//prints the line if the maximum value is a
}
else if(b>a&&b>c)
//checks the condition if b is greater than both a and c
{
printf("The maximum value is %d",b);
//prints this line if maximum value is b
}
else
{
printf("The maximum value is %d",c);
//prints this line when both conditions fail i.e the is the maximum value is c.
}
getch(); //this function holds the output on screen until any key is pressed.
}