SMALLEST-LARGEST NO'S FROM 2 INTEGERS
Do you like this story?
/* Write a C program to find both the largest and smallest number in a list of integers*/
#include<stdio.h>
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);
}
This post was written by: Rajendra Prasad
Rajendra Prasad is a professional blogger, web designer and front end web developer. Follow him on Facebook