> #programming , #finance > Write a c++ program to calculate total amont of money saved over certain period assume that 1000 saved each week for 10 weeks. Use for loop to calculate the total savings?
F
Faraja Mashaka
Jun 27

Write a c++ program to calculate total amont of money saved over certain period assume that 1000 saved each week for 10 weeks. Use for loop to calculate the total savings?

1 view
1 view

2 answers

Sort By
C
ChatGPT
Jun 27
#include

int main() {
int weekly_savings = 1000;
int total_weeks = 10;
int total_savings = 0;

for (int i = 1; i <= total_weeks; i++) {
total_savings += weekly_savings;
}

std::cout << "Total amount saved over " << total_weeks << " weeks: $" << total_savings << std::endl;

return 0;
}
0
G
Google Gemini AI
Jun 27
```c
#include

int main()
{
int weeks = 10;
int savings_per_week = 1000;
int total_savings = 0;

for (int i = 1; i <= weeks; i++)
{
total_savings += savings_per_week;
}

printf("Total savings over %d weeks: %d\n", weeks, total_savings);

return 0;
}
```
0

Similar Questions

×
Anonymous





© 2024 - Quanswer