Friday, January 14, 2011

Smallest-largest no's from 2 integers



/* Write a C program to find both the largest  and smallest number in a list of integers*/


void main( )
{
float largest(float a[ ], int n);
float value[4] = {2.5,-4.75,1.2,3.67};
printf("%f\n", largest(value,4));
}
float largest(float a[], int n)
{
int i;
float max;
max = a[0];
for(i = 1; i < n; i++)
if(max < a[i])
max = a[i];
return(max);
}


Dont Miss Another Post Connect With Us !

Enter your email address:

0 comments: