Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge | Intro to Arrays
Introduction to C++
course content

Contenido del Curso

Introduction to C++

Introduction to C++

1. Basics
2. Variables
3. Conditional Statements
4. Loops
5. Intro to Arrays

Challenge

Let's practice!

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 5. Capítulo 4
toggle bottom row

Challenge

Let's practice!

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 5. Capítulo 4
toggle bottom row

Challenge

Let's practice!

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Let's practice!

Tarea

Lily went to the shop to buy some clothes. It was the sales day so all the clothes she bought were at discount. Let’s calculate the total discount she got.

We have two arrays of the same length (6): prices and sales. The first array stores prices (in dollars) for Lily’s clothes and the second one stores discounts (in percent, 0.1 means that the thing has a 10% discount) for the corresponding clothes.

You should:

  1. Use for loop to go through the arrays, don't forget to open curly brackets.
  2. Calculate the discount for each thing by multiplying the corresponding elements of two arrays and store the result in the variable discountForEach.
  1. To find the sum of all discounts, add variables discountForEach and totalDiscount, and store the result in the variable totalDiscount.
  1. Close curly brackets.
  2. Print the variable totalDiscount.

Please, don’t forget to type the semicolon at the end of the lines.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 5. Capítulo 4
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt