Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Loop For | Introdução a fluxo de programa
Introdução ao C++
course content

Conteúdo do Curso

Introdução ao C++

Introdução ao C++

1. Primeiros Passos
2. Variáveis e Tipos de Dados
3. Introdução Aos Operadores
4. Introdução a fluxo de programa
5. Introdução a Funções

Loop For

O loop for é mais complexo do que os outros loops e consiste em três partes. Estrutura do loop for:

  • Contador;
  • Condição de saída;
  • Expressão do loop.
cpp

main

copy
123456789
#include <iostream> int main() { for (int counter = 0; counter <= 5; counter++) { std::cout << counter << std::endl; } }
  • int counter = 0: iteration counter;
  • counter++: For each iteration, 1 will be added to the counter variable to mark the passage of the loop;
  • counter <= 5: loop termination condition. The loop will continue if the counter variable is less than or equal to 5.

Quantas iterações esse loop realizará?

Selecione a resposta correta

Tudo estava claro?

Seção 4. Capítulo 6
We're sorry to hear that something went wrong. What happened?
some-alt