max of 4 by ternary

PHOTO EMBED

Sat Oct 28 2023 07:00:40 GMT+0000 (Coordinated Universal Time)

Saved by @yolobotoffender

//program to find max of 4 integers;
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
  int n1,n2,n3,n4,max;
  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 > n4 ? n3 : n4));
  cout<<max<<endl;

    return 0;
}
content_copyCOPY