Pages

Write a program in c language to find minimum number from array

Tuesday 1 July 2014

#include <stdio.h>
#include <conio.h>

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

    printf("How many elements you want to enter in array: ");
    scanf("%d",&size);

    printf("Enter %d integers: ", size);

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

    min = array[0];

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

    printf("Minimum element is located at location %d and value is %d: ", location, min);
    getch();
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *