Quantcast
Viewing all articles
Browse latest Browse all 9

C language: Program for finding minimum number in an Array

This is one of another programs that are asked in interviews to freshers which asks for finding minimum number in a given array.  In this program we make a function which compares all the given numbers in an array and then finds the number with the minimum value in the array.

Here’s the code for finding the minimum number in an array in C language

#include <stdio.h>

int main()
{
 int array[100], minimum, size, c, location = 1;

 printf("Enter the number of elements in array\n");
 scanf("%d",&size);

 printf("Enter %d integers\n", size);

 for ( c = 0 ; c < size ; c++ )
 scanf("%d", &array[c]);

 minimum = array[0];

 for ( c = 1 ; c < size ; c++ )
 {
 if ( array[c] < minimum )
 {
 minimum = array[c];
 location = c+1;
 }
 }

 printf("Minimum element is present at location %d and it's value is %d.\n", location, minimum);
 return 0;
}


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 9

Trending Articles