Header Ads

C program for smallest of n numbers

#include<stdio.h>
#include<conio.h>
int main()
{
  int n;
  printf("Enter the values of n: ");
  scanf("%d",&n);
  void smallest(int);
  smallest(n);
  getch();
}
void smallest(int n1)
{
 int small,num,i;
 printf("Number %d: ",1);
    scanf("%d",&small);
 for(i=2;i<=n1;i++)
 {

    printf("Number %d: ",i);
    scanf("%d",&num);

    if(small>num)
      small=num;
  }

  printf("smallest number is: %d",small);
}

Output:

Screenshot for smallest of n number
Related programs:
1.       Largest of n numbers.

No comments