C Online Compiler
Example: Print Descending Series with For Loop in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Print Descending Series with For Loop #include <stdio.h> int main() { // Step 1: Declare an integer variable 'i' to serve as the loop counter. // Step 2: Initialize 'i' to 5 (the starting number). // Step 3: Set the loop condition: continue as long as 'i' is greater than or equal to 1. // Step 4: Specify the iteration step: decrement 'i' by 1 in each cycle. for (int i = 5; i >= 1; i--) { // Step 5: Print the current value of 'i' followed by a space. printf("%d ", i); } // Step 6: Print a newline character at the end for clean output. printf("\n"); return 0; }
Output
Clear
ADVERTISEMENTS