Computer Science, asked by mokshpriya05081998, 8 months ago

write a c program to find minimum number in a given list of N integers

Answers

Answered by visheshsaxena49
4

Answer:

int a[10],smallest,i;

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

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

smallest=a[0];

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

{

if ( a[i] <smallest)

{

smallest=a[i];

}

}

printf("\nSmallest number is %d", smallest);

Answered by vk3267517
0

Answer:

The answer is :

#include<stdio.h>

int main() {

  int a[30], i, num, smallest;

  printf("\nEnter no of elements :");

  scanf("%%d", &num);

  //Read n elements in an array

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

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

  //Consider first element as smallest

  smallest = a[0];

  for (i = 0; i < num; i++) {

     if (a[i] < smallest) {

        smallest = a[i];

     }

  }

  // Print out the Result

  printf("\nSmallest Element : %d", smallest);

  return (0);

}

Output :

Enter no of elements : 5

11\\ 44 \\22\\ 55\\ 99\\

Smallest Element : 11

Explanation:

C program to find the smallest of n numbers in a given array

Logic. We start to iterate and then compare all the elements with each other and store the smallest element in the variable named 'small' and then keep comparing till we find the smallest element.

1. Dry Run of the Program. ...

2. Program. ...

3. Output.

Hence, the answer is to Enter no of the elements : 5

11\\ 44 \\22\\ 55\\ 99\\

Smallest Element : 11

#SPJ2

Similar questions