Showing posts with label Write a C program to find both the largest and smallest number in a list of integers. Show all posts
Showing posts with label Write a C program to find both the largest and smallest number in a list of integers. Show all posts

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

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


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);

}

Labels