For Loop Pattern Programs in C Programming


For Loop Pattern Programs in C Programming refers to a specific type of program that uses for loops to generate a specific pattern or shape. These programs use nested for loops and conditional statements to print characters such as stars, numbers, letters, etc. in a specific pattern. This type of program is commonly used to practice and improve understanding of loops and conditional statements in C programming. Examples of patterns that can be created with for loop include pyramid, diamond, triangle, and many more

for loop pattern programming

Source Code Example : 1

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf("%d",i);
    }
  }
  return 0;
}

To download raw file Click Here

Output

Enter the value:5
1
22
333
4444
55555

This program is about print the pattern as number up to the given limits using For Loop

Source Code Example : 2

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf("%d",j);
    }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
1
12
123
1234
12345

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example : 3

#include<stdio.h>
int main()
{
  int i,j,a,b=1;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf(" %d",b);
      b++;
    }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

This program is about print the pattern as number up to the given limits using For Loop

Source Code Example : 4

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf("%d",(i-j+1));
    }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
1
21
321
4321
54321

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example :5

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
   printf("\n");
   for(j=1;j<=(a-i);j++)
   {
     printf(" ");
   }
   for(j=1;j<=i;j++)
   {
    printf("%d",j);
   }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
    1     
   12
  123
 1234
12345

This program is about print the pattern as numbers up to the given limit using For Loop

Source Code Example :6

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
     printf("\n");
     for(j=a-i+1;j>0;j--)
     {
       printf("%d",j);
     }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
54321
4321
321
21
1

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example : 7

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf(" ");
    }
    for(j=1;j<=(a-i+1);j++)
    {
      printf("%d",j);
    }
  }
  return 0;
}

To download raw file Click Here

Output

Enter the value:5
12345
 1234
  123
   12
    1

This program is about print the pattern number as diamond using For Loop

Source Code Example : 8

#include<stdio.h>
int main()
{
  int i,j,n;
  printf("\nEnter the value :");
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    printf("\n");
    for(j=1;j<=(n-i);j++)
    {
        printf("  ");
    }
    for(j=1;j<=i;j++)
    {
        printf(" %d",j);
    }
    for(j=1;j<i;j++)
    {
        printf(" %d",(i-j));
    }
  }
  for(i=1;i<=n;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf("  ");
    }
    for(j=1;j<(n-i);j++)
    {
       printf(" %d",j);
    }
    for(j=(n-i);j>0;j--)
    {
       printf(" %d",j);
    }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value: 5
     1
   1 2 1
  1 2 3 2 1
 1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
 1 2 3 4 3 2 1
   1 2 3 2 1
    1 2 1
     1

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example : 9

#include<stdio.h>
int main()
{
  int i,j,a;
  printf("\nEnter the value:");
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
     printf("\n");
     for(j=i;j>0;j--)
     {
       printf("%d",j);
     }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value: 5
1
21
321
4321
54321

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example :10

#include<stdio.h>
int main()
{
  int i,j,n;
  printf("\nEnter the value:");
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    printf("\n");
    for(j=n-i;j<=n;j++)
    {
      printf("%d",j);
    }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
5
45
345
2345
12345

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example : 11

#include<stdio.h>
int main()
{
  int i,j,n;
  printf("\nEnter the value:");
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    printf("\n");
    for(j=i;j<=n;j++)
    {
      printf("%d",j);
    }
  }
  return 0;
}      
To download raw file Click Here

Output

Enter the value:5
12345
2345
345
45
5

This program is about print the pattern as numbers up to the given limits using For Loop

Source Code Example :12

#include<stdio.h>
int main()
{
  int i,j,n;
  printf("\nEnter the value:");
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    printf("\n");
    for(j=1;j<=i;j++)
    {
      printf(" ");
    }
    for(j=n;j>=i;j--)
    {
      printf("%d",j);
    }
  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
54321
 5432
  543
   54
    5

This program is about print the pattern number as reverse diamond using For Loop

Source Code Example : 13

#include<stdio.h>
int main()
{
  int i,j,n;
  printf("\nEnter the value:");
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    printf("\n");
    
    for(j=1;j<=n-i;j++)
    {
       printf("  ");
    }
    for(j=n;j>n-i;j--)
    {
       printf(" %d",j);
    }
    for(j=n-i+2;j<n+1;j++)
    {
       printf(" %d",j);
    }
  }
  for(i=1;i<=n;i++)
  {
    printf("\n");

    for(j=1;j<=i;j++)
    {
       printf("  ");
    }
    for(j=n;j>i;j--)
    {
       printf(" %d",j);
    }
    for(j=i+2;j<=n;j++)
    {
       printf(" %d",j);
    }

  }
  return 0;
}
To download raw file Click Here

Output

Enter the value:5
        5
      5 4 5
    5 4 3 4 5
  5 4 3 2 3 4 5 
5 4 3 2 1 2 3 4 5
  5 4 3 2 3 4 5
    5 4 3 4 5
      5 4 5
        5

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C