jeudi 20 décembre 2018

how to make the function conditional ternary statement using

i want this user defined to work in conditional ternary operator passing the value , using the concept of if else and elseif in ternary conditional operator

#include <iostream> //Conditional Ternary Operator (if ? :else )
using namespace std;
int greatest(int a,int b,int c)
{
    (a>b && a>c) ?return (a); :(b>a && b>c) ?return (b); :return(c);

  /* if(a>b && a>c)
  return(a);
  else if (b>a && b>c)
    return (b);
  else
    return(c);
  */
}
 int main()
{
 int a,b,c;
 cout<<"Enter a :";
 cin>>a;
 cout<<"Enter b :";
 cin>>b;
 cout<<"Enter c:";
 cin>>c;
 cout<<greatest(a,b,c)<<": Is Greater";
 return 0;
}

Aucun commentaire:

Enregistrer un commentaire