Video tutorial to find the biggest of the three integer numbers in C++, using if-else control statements and Ternary Operator.
Before watching this video, please make sure to watch and understand this short video: Find Biggest of 3 Numbers: C++
Full Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<iostream .h> #include<conio .h> void main() { int a, b, c; clrscr(); cout< <"Enter 3 no's\n"; cin>>a>>b>>c; int big = ( a>b && a>c )?a:(b>c?b:c); /* if( a > b && a > c ) big = a; else if( b > c ) big = b; else big = c; */cout< <"\nAmong "<<a<<" , "<<b<<" , "<<c<<" Biggest is "<<big; getch(); } |
In this program we take 3 integer values from the user and using ternary operator decide the biggest of 3 numbers.
int big = ( a>b && a>c )?a:(b>c?b:c); |
if ( a > b && a > c ) is true, then value of a will be stored in variable big; else ( b > c ? b : c ) will be evaluated. Here, if value of b is greater than c, value of b will be stored in variable big else value of c will be stored in the variable big.
Video Tutorial: Biggest of 3 Integer Numbers
[youtube https://www.youtube.com/watch?v=gfmqT4PwfY0]
Output
Enter 3 no’s
10
20
30
Among 10, 20, 30 Biggest is 30
Simple problem for your students…
I have 1 to 100 numbers jumbled, i mean they are not in sequence..
example: 99,2,45,12,66,…like this numbers are jumbled and numbers are within 100 only..
I have one number missed..so now i have 99 numbers jumbled,,i want to find that missed number..find it..
example: 8,3,1,5,9,2,6,7,10 (numbers are jumbled, and numbers between 1 to 10)
missed number is: 4
Thanks Shwetha, for letting us know about this.
Guys/Girls, follow this thread for the answer https://technotip.com/forums/topic/find-the-missing-number-in-a-random-rang-of-unordered-numbers-cpp/