Saturday 19 January 2013




C program that finds the smallest number by using id statement.

#include<stdio.h>
void main ()
{
      int a,b,c,d;
      int smallest_num=0;
      printf("Enter first number  :");
      scanf("%d",&a);
      printf("Enter second number :");
      scanf("%d",&b);
      printf("Enter third number :");
      scanf("%d",&c);
      printf("Enter fourth number :");
      scanf("%d",&d);
      if(a<b &&a<c  && a<d)
      {
            smallest_num=a;
            printf("Smallest number  is %d ",a);
      }
      if(b<a &&b<c && b<d)
      {
            smallest_num=b;
            printf("Smallest number  is %d ",b);
      }
      if(c<a && c<b && c<d )
      {
            smallest_num=c;
            printf("Smallest number  is %d ",c);
      }
      if(d<a && d<b && d<c)
      {
            smallest_num=d;
            printf("Smallest number  is %d ",d);
      }
}
OUT PUT :

No comments:

Post a Comment