fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main () {
  4. int n, total = 0;
  5. cout << "Enter the no. of days:";
  6. cin >> n;
  7. for (int i = 1; i<= n; i++) {
  8. total = total + i;
  9. }
  10. cout << "Total savings is:" << " " << total;
  11. return 0;
  12.  
  13. }
  14.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Enter the no. of days:Total savings is: 536788995