Print number Pattern in C

Google 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 Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. If you want to post your article on our website/FB Group/FB Page please contact on hitesh.xc@gmail.com or 8076671483

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

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders. Difference between path and classpath in Java

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs