Thursday, 18 December 2014

C++ program to find greatest number between three numbers

  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. }

No comments:

Post a Comment