Simple solution to find largest & smallest number in array.

kabirk007's Avatar, Join Date: Dec 2008
Light Poster
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,large,small;
printf("enter the value of n\n");
scanf("%d",&n);
printf("enter the numbers\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
large=a[0];
small=a[0];
for(i=1;i<n;i++)
{
if(a[i]>large)
large=a[i];
if(a[i]<small);
small=a[i];}
printf("The largest number is %d\n",large);
printf("smallest number is %d\n",small);
getch();
}

Last edited by shabbir; 27Jan2009 at 14:53.. Reason: Code blocks
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Any reason to ask a question in this thread

FInd the largest number in array?

And post code here.

Thread closed.