Grupo
Control de Flujo en C++
Ojetivo
1. Usa un bucle para iterar del 10 al 1.
2. En cada iteración, imprime el número actual.
3. Prueba el programa para asegurarte de que los números se impriman en orden inverso, del 10 al 1.
Escribe un programa que imprima los números del 1 al 10 en orden inverso.
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 10 to 1
for (int i = 10; i >= 1; --i) {
cout << i << endl; // Print the current value of i (the number)
}
return 0; // Return 0 to indicate that the program executed successfully
}
Salida
10
9
8
7
6
5
4
3
2
1
Comparte este ejercicio C++