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

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

/*Write a C++ program to find the largest, smallest and second largest
of three numbers using simple if statement.*/

#include<iostream.h>

#include<conio.h>

void main( )

{

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

clrscr( );

cout<<"Enter the three numbers"<<endl;

cin>>a>>b>>c;

largest = a; //Assume first number as largest

if(b>largest)

largest = b;

if(c>largest)

largest = c;

smallest = a; //Assume first number as smallest

if(b<smallest)

smallest = b;

if(c<smallest)

smallest = c;

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

cout<<"Smallest Number is = "<<smallest<<endl;

cout<<"Second Largest Number is = "<<seclargest<<endl;

cout<<"Largest Number is = "<< largest<<endl;

getch( );

}

Write a C++ program to find the largest, smallest and second largest of three numbers using simple if statement Write a C++ program to find the largest, smallest and second largest of three numbers using simple if statement Reviewed by Vision Academy on February 27, 2022 Rating: 5

No comments:

CheckOut

Powered by Blogger.