C Program to Find Smallest of 3 Numbers using Conditional Operator

#include <stdio.h>
#include <conio.h>
void main()
{
  int x, y, z, temp, small;
  clrscr();
  printf ("Enter the value of 3 numbers: ");
  scanf ("%d%d%d", &x, &y, &z);
  temp = (x < y)    ? x : y;
  small =  (z < temp) ? z : temp;
  printf ("The Smallest of this 3 numbers: %d", small);
  getch();
}

Output:

C Program to Find Smallest of 3 Numbers using Conditional Operator

C Program to Find Smallest of 3 Numbers using if-else:

#include<stdio.h>
#include<conio.h>
void main()
{
    int a, b, c;
    clrscr();
    printf("Enter three Integer numbers: ");
    scanf("%d %d %d", &a, &b, &c);
    if((a < b)&&(a < c))
    {
       printf("The Smallest of this 3 numbers: %d",a);
    }
    else
     {
       if(b < c)
       printf("The Smallest of this 3 numbers: %d",b);
       else
       printf("The Smallest of this 3 numbers: %d",c);
      }
    getch();
 }

Output:

C Program to Find Smallest of 3 Numbers using if-else