Advertisement
Finalist

Untitled

Feb 2nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main(int argc, char* argv[])
  5. {
  6. int i,
  7. accountNumbers = 0;
  8. double numb,
  9. sum = 0;
  10.  
  11. std::cout << "Enter number of sequence---->" <<std::endl;
  12. std::cin >> i;
  13. std::cout << "Enter numbers: " << std::endl;
  14.  
  15. for (int j = 1; j <= i; j++)
  16. {
  17. std::string ending;
  18.  
  19. switch (j)
  20. {
  21. case 1:
  22. ending = "st";
  23. break;
  24. case 2:
  25. ending = "nd";
  26. break;
  27. case 3:
  28. ending = "rd";
  29. break;
  30. default:
  31. ending = "th";
  32. }
  33.  
  34. std::cout << "\n\rEnter " << j << ending << " number: " << std::endl;
  35. std::cin >> numb;
  36. std::cout << j << ending << " number is: " << numb << std::endl;
  37. sum += numb;
  38. accountNumbers++;
  39. }
  40.  
  41. std::cout << "\n\rThere are " << accountNumbers << " numbers, which whole Sum is: "
  42. << sum << std::endl << std::endl;
  43.  
  44. system("pause");
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement