C++ program to find greatest number between three numbers

Program description
This program shows the greatest number between three numbers using if-else-if statement. It takes three numbers as input from user and output the greatest number.

code:



  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int num1,num2,num3;
  6. cout<<" Enter value for first number";
  7. cin>>num1;

  8. cout<<" Enter value for second number";
  9. cin>>num2;

  10. cout<<" Enter value for third number";
  11. cin>>num3;
  12. if(num1>num2&&num1>num3)
  13. {
  14. cout<<" First number is greatest:"<<endl<<"whick is= "<<num1;
  15. }
  16. else if(num2>num1&&num2>num3)
  17. {
  18. cout<<" Second number is greatest"<<endl<<"whick is= "<<num2;
  19. }
  20. else
  21. {
  22. cout<<" Third number is greatest"<<endl<<"whick is= "<<num3;
  23. }
  24. return 0;
  25. }

Note : If you have any query or idea about program 
Comment below.





Bookc
Admin

Hopefully the information we provide can be useful.

Related Article

Press ESC to close