Greatest Number


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*
  2.  *GreatestNum.cpp
  3.  *This program will display the highest integer from the three numbers entered by the user.
  4.  *@MDPN
  5.  *@09072010
  6. */
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. int int1, int2, int3;
  13.  
  14. cout<<"\t\t\t Highest Number"<<endl
  15. <<"\t\t\t --------------"<<endl<<endl;
  16. cout<<"This program will display the highest integer entered by the user."
  17. <<endl<<endl<<endl;
  18.  
  19. cout<<"Please input 1st integer = ";
  20. cin>>int1;
  21. cout<<"Please input 2nd integer = ";
  22. cin>>int2;
  23. cout<<"Please input 3rd integer = ";
  24. cin>>int3;
  25. cout<<"\n\nThe highest number is ";
  26.  
  27. if(int1>int2 && int1>int3)
  28. {
  29. cout<<int1;
  30. }//end if
  31. else if(int2>int3 && int2>int1)
  32. {
  33. cout<<int2;
  34. }//end else-if
  35. else
  36. {
  37. cout<<int3;
  38. }//end else
  39. cout<<"."<<endl<<endl;
  40. return 0;
  41. }//end main

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.