Print number Pattern in C

Advertisements

Prev Tutorial Next Tutorial

Print Number Pattern Program in C

Hello friends today we focus on MNC compnies, like Amozon, Zoho, Infosys, Google, Yahoo Interview questions. In C language you can print any number Pattern using if else conditional concept and looping concept. Here i will show you how to print all number Pattern in c language with explanation. We provide you a most commonly asked number pattern question for your interview preparation using C programming Language.

print number pattern in c

C Program to Print Patterns of numbers

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

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

Output

1
23
456
78910

C Program to Print Patterns of numbers

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

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

getch();
}

Output

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

Print number Pattern in C

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

void 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");
  }
getch();
}

Output

      1
   2 3 4
5 6 7 8 9

C Program to Print Patterns of numbers

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

void main()
{
int i, j;
clrscr();
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");
}
getch();
}

Output

1
123
12345
1234567
12345
123
1

Example

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

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

Output

11111
22222
33333
44444
55555

Example

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

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

Output

54321
 4321
  321
   21
    1

C Program to Print Number Pattern

#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): 4
   1
  232
 34543
4567654

Print Number Pattern in C

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

void main()
{
    int i,j,n;
    clrscr();d
    printf("Enter no. of lines:\n");
    scanf("%d",&n);
 
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            if(i%2==1)
            {
                printf("1 ");
            }
            else
            {
                printf("0 ");
            }
        }
        printf("\n");
    }
getch();
}

Output

Enter no. of lines: 5
1
0 0
1 1 1
0 0 0 0
1 1 1 1 1

Print Number Pattern in C

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


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

   getch();
}

Output

11111
0000
111
00
1

Print Number Pattern in C

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

void main()
{
   int r,i,j;
   clrscr();
   printf("Enter The no. of rows: ");
   scanf("%d",&r);

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

   printf("\n");
   }
   getch();
}

Output

Enter The no. of rows: 5
11111
0000
111
00
1
print any number pattern in C
Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements