Advertisement
Spocoman

07. Print and Sum

Nov 2nd, 2023
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int firstNumber, secondNumber, sum = 0;
  7.     cin >> firstNumber >> secondNumber;
  8.  
  9.     for (int i = firstNumber; i <= secondNumber; i++) {
  10.         cout << i << ' ';
  11.         sum += i;
  12.     }
  13.  
  14.     cout << "\nSum: " << sum << endl;
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement