Sunday, August 13, 2023

Write a C Program to Find the Smallest Number among Three Numbers (integer values) using Nested IF-Else statement.


 Write a C Program to Find the Smallest Number among Three Numbers (integer values) using Nested IF-Else statement.


Program  :


#include <stdio.h>

int main()

{

    int n1, n2, n3; 

    scanf("%d %d %d", &n1, &n2, &n3);

if (n1<n2)

    {

        if(n1<n3)

            printf("%d is the smallest number.", n1);

        else

            printf("%d is the smallest number.", n3);

    }

    else

    {

        if(n2<n3)

            printf("%d is the smallest number.", n2);

        else

            printf("%d is the smallest number.", n3);

    }

}



InputOutput
Test Case 1
80 40 90
40 is the smallest number.
Test Case 2
77 88 -99
-99 is the smallest number.

No comments:

Post a Comment