For Loop Practice in C++
📖 Scenario: You are helping a small store owner who wants to calculate the total price of items sold. Each item has a price, and the owner wants to add them up using a simple loop.
🎯 Goal: Build a C++ program that uses a for loop to sum the prices of items in an array and print the total.
📋 What You'll Learn
Create an array called
prices with the exact values: 10, 20, 30, 40, 50Create an integer variable called
total and set it to 0Use a
for loop with the variable i to iterate over the prices arrayAdd each price to
total inside the loopPrint the value of
total after the loop💡 Why This Matters
🌍 Real World
Summing prices is a common task in stores, shopping carts, and billing systems.
💼 Career
Understanding loops and arrays is essential for many programming jobs, especially those involving data processing.
Progress0 / 4 steps