Find Biggest of 2 Numbers: C++


Video tutorial to find the biggest of the two integer numbers in C++, using if-else control statements.

Full Source Code

  1.    
  2. #include < iostream .h >  
  3. #include < conio .h  ">  
  4.   
  5.   
  6. void main()  
  7. {  
  8. int a, b;  
  9. clrscr();  
  10.   
  11. cout< <"Enter 2 numbers\n"; 
  12. cin>>a>>b; 
  13.  
  14. int big; 
  15.  
  16. if( a > b ) 
  17.  big = a; 
  18. else 
  19.  big = b; 
  20.  
  21. cout< < endl << "among " << a << "="" and="" " << b<<"="" biggest= "" is="" " << big;  

In this program we get two integer variables from the user.
If value of variable a is bigger, then we store it inside the variable big; else we store the value of variable b inside variable big.
Finally display the value of variable big which contains the biggest number amongst the two values entered by the user.

Video Tutorial: Biggest of 2 Integer Numbers



YouTube Link: https://www.youtube.com/watch?v=awbq2gsDg3E [Watch the Video In Full Screen.]


Output
Enter 2 numbers
-100
0
Among -100 and 0 biggest is 0

Leave a Reply

Your email address will not be published. Required fields are marked *