fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N , total=0;
  6. cout<<"Enter the number of days: ";
  7. cin>>N;
  8. int * saves = new int[N];
  9. cout<<"Enter the saving for each day"<<endl;
  10. for(int i=0; i<N;i++){
  11. cin>> saves[i];
  12. }
  13. for(int i=0; i<N;i++){
  14. total+= saves[i];
  15. }
  16. cout<<"The total saving is: " <<total;
  17. return 0;
  18. }
Success #stdin #stdout 0s 5320KB
stdin
5
10
20
30
40
50
stdout
Enter the number of days: Enter the saving for each day
The total saving is: 150