#include <iostream>
int main() {
for (int i = 5; i >= 1; --i) {
std::cout << i << " ";
}
return 0;
}
- Include the necessary header file for input/output operations.
- Define the main function.
- Initialize a variable
i
with the value 5. - Start a for loop with the initialization, condition, and iteration parts.
- Check if
i
is greater than or equal to 1. - Execute the body of the loop if the condition is true.
- Output the current value of
i
followed by a space. - Decrement the value of
i
by 1. - Repeat steps 5-8 until the condition becomes false.
- End the for loop.
- Return 0 to indicate successful program execution.