Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Simple solution to find largest & smallest number in array. (http://www.go4expert.com/forums/simple-solution-largest-smallest-array-t15954/)

kabirk007 27Jan2009 14:51

Simple solution to find largest & smallest number in array.
 
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();
}


shabbir 27Jan2009 14:53

Re: Simple solution to find largest & smallest number in array.
 
Any reason to ask a question in this thread

FInd the largest number in array?

And post code here.

Thread closed.


All times are GMT +5.5. The time now is 21:14.