Design a program to find largest of four numbers

The logic behind the program is, Take four variable like a, b, c, d for numbers also take another variable like large for comparing among three numbers. First of all, assign the value of variable a into the large variable. Compare among three numbers with the large variable. If any one is find larger then you have to assign this variable value into the larger variable.

Example

#include <stdio.h>
#include<conio.h>
main()
{
int a,b,c,d;
int large;

clrscr();
printf("Enter four numbers:\n");
scanf("%d%d%d%d",&a,&b,&c,&d);
large=a;
if(b>large)
large=b;
if(c>large)
large=c;
if(d>large)
large=d;
printf("The largest number is %d",large);
}

Output Of the Given program is

Comments

Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites