7 Number Pattern Programs in C Programming

Number Pattern Programs


Write a C program for 7 Number Pattern Programs in C Programming. Here’s simple C program for 7 Number Pattern Programs in C Programming Language.


Here is source code of the C program for 7  Number Pattern Programs in C Programming. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.


Program  1 :


#include<stdio.h>

int main()
{
    int i,j, k=1;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<i;j++)
        {
            printf("%d ",k);
            k++;
        }
        printf("\n");
    }

   return 0;
}

Output : 


1
2 3
4 5 6
7 8 9 10

Process returned 0

Program 2 :


#include<stdio.h>

int main()
{
  int i, j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("%d ",i);
        }
        printf("\n");
    }

return 0;
}

Output :


1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Process returned 0

Program  3 :


#include<stdio.h>

int main()
{
  int i,j,k;
  k=1;
  for(i=1;i<=5;i+=2)
  {
    for(j=5;j>=1;j--)
    {
      if(j>i)
        printf(" ");
      else
        printf("%d ",k++);
    }
    printf("\n");
  }
return 0;
}

Output :


    1
  2 3 4
5 6 7 8 9

Process returned 0

Program  4 :


#include<stdio.h>

int main()
{
    int i, j;
    for(i=1;i<=7;i+=2)
    {
        for(j=1;j<=i;j++)
            printf("%d ",j);
        printf("\n");
    }
    for(i=5;i>=1;i-=2)
    {
        for(j=1;j<=i;j++)
            printf("%d ",j);
        printf("\n");
    }
    return 0;
}

Output :


1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5
1 2 3
1

Process returned 0

Program  5  :


#include<stdio.h>

int main()
{
    int i, j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
            printf("%d ",i);
        printf("\n");
    }

}

Output : 


1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5

Process returned 0

 


Program 6 : 


#include<stdio.h>

int main()
{
    int i, j;

    for(i=5;i>=1;i--)
    {
        for(j=5;j>=1;j--)
        {
            if(j>i)
                printf(" ");
            else
                printf("%d ",j);
        }
        printf("\n");
    }

    return 0;
}

Output :


5 4 3 2 1
 4 3 2 1
  3 2 1
   2 1
    1

Process returned 0

Program  7 :


#include<stdio.h>
#include<conio.h>

void main()
{
int n, c, d, num = 1, space;
clrscr();
printf("Enter any number (1-10): ");
scanf("%d",&n);
space=n-1;
for(d=1; d<=n; d++)
{
num=d;
for(c=1; c<=space; c++)
printf(" ");
space--;
for(c=1; c<=d; c++)
{
printf("%d", num);
num++;
}
num--;
num--;
for(c=1; c<d; c++)
{
printf("%d", num);
num--;
}
printf("\n");
}
getch();
}

Output :


Enter any number (1-10): 6
     1
    232
   34543
  4567654
 567898765
67891011109876

Process returned 0

Above is the source code for C program for 7 Number Pattern Programs in C Programming which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

Leave a Reply