Monday, July 22, 2013

Program to find the largest number from a set of 'n' numbers

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,lrg,a;
cout<<"Enter the number of numbers : ";
cin>>n;
cout<<"Enter a number : ";
cin>>lrg;
while(n>1)
{
    cout<<"Enter a number : ";
    cin>>a;
    if(a>lrg)
    lrg=a;
    n--;
}
cout<<"Largest number is : "<<lrg;
getch();
}

No comments:

Post a Comment