Computer Science, asked by deepakanand26121999, 2 months ago

1. Write a 'C' program to find the second largest number among 3 numbers
given as input.​

Answers

Answered by EliteDaMyth
0

#include<stdio.h>

int main()

{

   printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");

   double a, b, c;

   printf("Enter 3 numbers:\n");

   scanf("%lf%lf%lf", &a, &b, &c);  //lf is a format specifier to take double as input

   // a is the largest

   if(a >= b && a >= c)

   {

       if(b >= c)

       {

           /*

               .2lf restricts the number till  

               2 decimal places

           */

           printf("\n\n%.2lf is the 2nd largest number\n", b);

       }

       else

       {

           printf("\n\n%.2lf is the 2nd largest number\n", c);

       }

   }

   else if(b >= a && b >= c)

   {

       if(a >= c)

       {

           printf("\n\n%.2lf is the 2nd largest number\n",a);

       }

       else

       {

           printf("\n\n%.2lf is the 2nd largest number\n",c);

       }

   }

   // c is the largest number of the three

   else if(a >= b)

   {

       printf("\n\n%.2lf is the 2nd largest number\n", a);

   else

   {

       printf("\n\n%.2lf is the 2nd largest number\n", b);

   }

   return 0;

}

Answered by shaikhshabira752
0

Answer:

j

hope it helps you thank you

Attachments:
Similar questions