Solved programming problem

How to find the minimum value in 1D array.

Source code

#include<stdio.h>

int main()

{

    int array[100];/// declare a 1D Array.

    int i,n,min;

    printf("
Please Enter The array size:");

    scanf("%d",&n);

    printf("
Please Enter %d Element Of the array: 
",n);

    for(i=0; i<n; i++) ///scan array element

    {

        scanf("%d",&array[i]);

    }

    min=array[0];///Set the 1st element as minimum value.

    for(i=0; i<n; i++)

    {

        if(array[i]<min)///checking if any number is smaller then or not

        {

            min=array[i];///if found,replace that.

        }

    }

    printf("
The min value is: %d
",min);

    return 0;

}

Output

Please Enter The array size:3

Please Enter 3 Element Of the array:

16 0 -5

The min value is: -5

Join the discussion

Add your comment

1 previous comment

Maniche

[url=https://oscialipop.com]Cialis[/url] cialis diaria Qozpfw Xvtyyc taking cialis followed by ambien <a href=https://oscialipop.com>buy cialis viagra</a> Hplfaf An omphalocele omphalo umbilicus navel is a herniation of the intestines through a weakness in the abdominal wall around the navel occurring in infants at birth. Swelling of the lower leg a. Lrnsia https://oscialipop.com - Cialis Immunoglobulins are separated from other plasma proteins by electrophoresis. Auojwq