MartinPaunov

SumNumbers

Apr 30th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.  
  5.     int n;
  6.  
  7.     std::cin >> n; /// -> enter the count of n -> numbers
  8.  
  9.     int sum = 0;
  10.  
  11.     for(int i = 0; i < n; i++){
  12.         int currentNum;
  13.         std::cin >> currentNum; ///-> reads current num from the console
  14.  
  15.         if (currentNum >= 4 && currentNum <= 14){
  16.             sum += currentNum;
  17.         }
  18.     }
  19.  
  20.     std::cout << sum << std::endl; /// -> prints the total sum of numbers
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment