Find the minimum number in C Program

How to write a C program to find the minimum number in C programming ?


Solution:
#include <stdio.h>

int main()
{
int a[100];
int n, i;
int min;

printf("How many numbers?\n");
scanf("%d", &n);

for(i = 0; i < n; i++)
{
printf("Enter number %d: ", i+1);
scanf("%d", &a[i]);
}

min = a[0];
for(i = 1; i < n; i++)
if(a[i] < min)
min = a[i];

printf("Minimum is: %d\n", min);

return 0;
}


Learn More :