18: Write a program to find maximum number using conditional operator.

 

18: Write a program to find maximum number using conditional operator.

 

Please follow me for more practicals....


Program:

#include <stdio.h>

#include <conio.h>

 

void main()

{

    clrscr();

    int num1, num2, max;

    printf("Enter num1 = ");

    scanf("%d", &num1);

    printf("Enter num2 = ");

    scanf("%d", &num2);

 

    max = (num1 > num2) ? num1 : num2;

    printf("\nMax number is %d", max);

    getch();

}

 

Please follow me for more practicals....


Output:

Enter num1 = 5

Enter num2 = 8

 

Max number is 8

 

Please follow me for more practicals....


Algorithm:

Step-1: START

Step-2: Declare num1, num2, max.

Step-3: Enter the value of num1 and num2.

Step-4: if(num1 > num2) then goto step-5 else goto step-6.

Step-5: max = num1.

Step-6: max = num2.

Step-7: Display max.

Step-8: STOP.

 

Please follow me for more practicals....


Flowchart:


Please follow me for more practicals....


Post a Comment

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