DESCRIPTION-:THIS PROGRAM FINDS GREATER BETWEEN THREE NUMBERS WITH
THE HELP OF TERNARY OPERATOR .
SYNTAX FOR TERNARY OPERATOR IS-:
EXPRESSION 1?EXPRESSION 2:EXPRESSION 3;
TERNARY OPERATOR IS ONE IN WHICH IF THE CONDITION IS TRUE(i.e EXPRESSION 1) THEN IT EXECUTE EXPRESSION 2, ELSE IT EXECUTE EXPRESSION 3.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d;
cout<<"enter three no.";
cin>>a>>b>>c;
d=((a>b&&a>c)?a:(b>a&&b>c)?b:c);
cout<<"greater no is"<<d;
getch();
}
THE HELP OF TERNARY OPERATOR .
SYNTAX FOR TERNARY OPERATOR IS-:
EXPRESSION 1?EXPRESSION 2:EXPRESSION 3;
TERNARY OPERATOR IS ONE IN WHICH IF THE CONDITION IS TRUE(i.e EXPRESSION 1) THEN IT EXECUTE EXPRESSION 2, ELSE IT EXECUTE EXPRESSION 3.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d;
cout<<"enter three no.";
cin>>a>>b>>c;
d=((a>b&&a>c)?a:(b>a&&b>c)?b:c);
cout<<"greater no is"<<d;
getch();
}
0 comments:
Post a Comment