-->

Friday, November 14, 2014

Design a program to find largest of four numbers

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

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved