Grupo
Control de Flujo en C++
Ojetivo
1. Usa un bucle for para iterar del 1 al 100.
2. En cada iteración, imprime el número actual.
3. Prueba el programa para asegurarte de que imprime todos los números del 1 al 100.
Imprime los números del 1 al 100 usando un bucle for.
Ejemplo de Código C++
Mostrar Código C++
#include <iostream> // Include the iostream library for input and output
using namespace std; // Use the standard namespace
// Main function - the entry point of the program
int main() {
// Use a for loop to iterate from 1 to 100
for (int i = 1; i <= 100; ++i) {
cout << i << endl; // Print the current value of i
}
return 0; // Return 0 to indicate that the program executed successfully
}
Salida
1
2
3
4
5
6
7
8
9
10
...
99
100
Comparte este ejercicio C++