Smallest among the 3 numbers – C Program


Write a C program to find the smallest among the 3 numbers given as input. [Dec 2015, Set-3]

#include <stdio.h>

int main()
{
    int num1, num2, num3;

    printf("Enter three integers :");
    scanf("%d%d%d", &num1, &num2, &num3);

    if (num1 < num2 && num1 < num3)
    {
        printf("Smallest number is %d.", num1);
    }
    else if (num2 < num3)
    {
        printf("Smallest number is %d.", num2);
    }
    else
    {
        printf("Smallest number is %d.", num3);
    }

    return 0;
}