C Language Tasks for Beginners

 

 Code :

#include <stdio.h>
int main()
{
    int i, j;
    for (i = 5; i >= 1; i--)
    {
        for (j = i; j <= 5; j++)
        {
            printf("%d", j);
        }
        printf("\n");
    }
    return 0;
}
  • Header File: #include <stdio.h> is needed to use printf() for printing output.
  • Main Function: The program starts from int main(). It returns 0 to indicate successful completion.
  • Outer Loop (Rows): The outer for loop (i = 5 to i >= 1) controls the number of rows. Each row starts with i and prints numbers up to 5.
  • Inner Loop (Columns): The inner for loop (j = i to j <= 5) prints numbers starting from the current value of i up to 5 for each row.
  • New Line: printf("\n"); moves the output to a new line after printing each row.

Output :

5
45
345
2345
12345