google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a program to find the largest, smallest and second largest of three numbers using simple if statement - 2nd puc computer science

Write a program to find the largest, smallest and second largest of three numbers using simple if statement

 Write a program to find the largest, smallest and second largest of three numbers using simple if statement

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,largest,smallest,secondlargest;

clrscr();

printf("Enter three numbers\n");

scanf("%d%d%d",&a,&b,&c);

largest=a;

smallest=a;

if(b>largest)

largest=b;

if(c>largest)

largest=c;

if(b<smallest)

smallest=b;

if(c<smallest)

smallest=c;

secondlargest=(a+b+c)-(largest+smallest);

printf("Largest number is %d",largest);

printf("\nSecond Largest number is %d",secondlargest);

printf("\nSmallest number is %d",smallest);

getch();

}

Output:

Enter three numbers

4                                                                              

2                                                                             

6                                                                              

Largest number is 6                                                            

Second Largest number is 4                                                     

Smallest number is 2                   

Write a program to find the largest, smallest and second largest of three numbers using simple if statement  Write a program to find the largest, smallest and second largest of three numbers using simple if statement Reviewed by Vision Academy on December 07, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.