Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Practicing With Loops | Introduction to Program Flow
C++ Introduction

book
Practicing With Loops

Task

Swipe to start coding

In a banking system, every customer receives reward points based on their position in the queue. The reward starts at 100 points and increases by 50 points for every subsequent customer. Write a program to calculate and output the reward for the 15th customer using a loop structure.

Solution

cpp

solution

#include <iostream>

int main()
{
// reward variable
int reward = 100;

// Calculate reward for the 15th customer
for (int customer = 0; customer < 15; customer++)
{
reward += 50; // Add the increment to the reward
}

std::cout << "The reward for the 15th customer is: " << reward << " points." << std::endl;
}
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 6
#include <iostream>

int main()
{
// reward variable
___ ___ = ___;
// Calculate reward for the 15th customer
for (int customer = 0; ___; ___)
{
___ += ___;
}

std::cout << "The reward for the 15th customer is: " << ___ << " points." << std::endl;
}
toggle bottom row
some-alt