NAV BAR

Monday 8 August 2016

To find Smallest number in C

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,n,a[100],small;
    printf("Enter number of element");
    scanf("%d",&n);
    printf("Enter value of each element");
    for(i=0;i<n;i++)
    {
       scanf("%d",&a[i]);
    }

    small = a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]<small)
        {
            small = a[i];
        }
    }
    printf("Smallest element is %d",small);
    getch();
}

No comments:

Post a Comment