Tuesday 24 February 2015

Finding Biggest and Smallest In List of Numbers Using C++

#include<iostream.h>
#include<conio.h>
main()
{
int a[100],n,i,j=0;
clrscr();
cout<<"\n How Many Numbers You Want Give Input\n";
cin>>n;
cout<<"\n Enter Your Numbers\n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
i=0;
while(i<n)
{
if(a[i]>j)
{
j=a[i];
}
i++;
}
cout<<"\n Biggest No is :"<<j;
i=0;
j=a[i];
i++;
while(i<n)
{
if(a[i]<j)
{
j=a[i];
}
i++;
}
cout<<"\n Smallest No is   :"<<j;
getch();
}

No comments:

Post a Comment