max and 2nd max
Sat Oct 28 2023 09:08:14 GMT+0000 (Coordinated Universal Time)
Saved by
@yolobotoffender
//program to find max and second max of 4 integers;
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
int n1,n2,n3,n4,max,max2;
cout<<"enter 4 numbers "<<endl;
cin>>n1>>n2>>n3>>n4;
max =(n1>n2)?(n1>n3?(n1>n4?n1:n4):(n3>n4)?n3:n4):(n2>n3)?(n2>n4?n2:n4):n3;
cout<<"max is: "<<max<<endl;
max2=(n1>n2)?(n2>n3?(n2>n4?n2:n4):n3):(n1>n3)?(n1>n4?n1:n4):n3;
cout<<"2nd max is: "<<max2<<endl;
return 0;
}
content_copyCOPY
Comments