Search This Blog


Saturday, 20 April 2019

C Program to Find the Biggest of 3 Numbers

WELCOME BACK TO codejunction.in , hope you are enjoying our blogs , just give more time to check out some of our latest blogs .


IN THIS PROGRAM THE USER NEEDS TO ENTER 3 NUMBERS AND THE PROGRAM WILL FIND THE BIGGEST OF 3 NUMBERS.


Problem Solution
1. Take the three numbers as input.
2. Check the first number if it greater than other two.
3. Repeat the step 2 for other two numbers.
4. Print the number which is greater among all and exit.

CODE

 #include <stdio.h>
 void main()
 {
     int num1, num2, num3;
  
     printf("Enter the values of num1, num2 and num3\n");
     scanf("%d %d %d", &num1, &num2, &num3);
     printf("num1 = %d\tnum2 = %d\tnum3 = %d\n", num1, num2, num3);
     if (num1 > num2)
     {
         if (num1 > num3)
         {
             printf("num1 is the greatest among three \n");
         }
         else
         {
             printf("num3 is the greatest among three \n");
         }
     }
     else if (num2 > num3)
         printf("num2 is the greatest among three \n"); 
    else
        printf("num3 is the greatest among three \n");
 }

OUTPUT


No comments:

Post a Comment