19: Write a program to minimum number from three number using conditional operator.

19: Write a program to minimum number from three number using conditional operator.

 

Please follow me for more practicals....


Program:

 

#include <stdio.h>

#include <conio.h>

 

void main()

{

    clrscr();

    int num1, num2, num3, minNum;

 

    printf("Enter the 1st number = ");

    scanf("%d", &num1);

 

    printf("Enter the 2nd number = ");

    scanf("%d", &num2);

 

    printf("Enter the 3rd number = ");

    scanf("%d", &num3);

 

    minNum = num1 < num2 ?

    num1 < num3 ? num1 : num3 :

    num2 < num3 ? num2 : num3;

    printf("\n\nThe maximum number = %d", minNum);

 

    getch();

}

 

Please follow me for more practicals....

 

Output:

 

Enter the 1st number = 3

Enter the 2nd number = 4

Enter the 3rd number = 5

 

 

The maximum number = 3

 

Please follow me for more practicals....


Algorithm:

1.      START

2.      Declare num1, num2, num3, minNum.

3.      Enter the value of num1, num2, num3.

4.      if (num1 < num2) then goto step 5 else goto step 8.

5.      if (num1 < num3) then goto step 6 else goto step 7.

6.      minNum = num1.

7.      minNum = num3.

8.      if (num2 < num3) then goto step 9 else goto step 10.

9.      minNum = num2.

10.   minNum = num3.

11.   display minNum.

12.   STOP

 

Please follow me for more practicals....

Flowchart: 



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.