Number Patterns in C.

A program to print number patterns in C.

 

Number Patterns: In C language you can print any number pattern. Here i will show you

                                     how to print all number pattern with explanation.

 

Let’s write program to print number patterns.

 

Let’s open turbo C and write the following code.

 

Code:

 

// Add preprocessor

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,n;

 

// Clear Screen

clrscr();

printf(“enter range of numbers:”);

scanf(%d”,&n);

for(i=1;i<=n;i++)

{

for(j=1;j<=n;j++)

{

printf(“10\t”);

}

printf(“\n”);

}

getch();

}

 

Output:

 

 

oUtput

 

Or ,if you will not use “ \t” in program then its output will :

 

OUTPUT

 

 

A program to print triangle of numbers.

 

Code:

 

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,n;

printf(“enter range of number:);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{

for(j=1;j<=i;j++)

{

printf(“10”);

}

printf(“\n”);

}

getch();

}

 

Output:

 

2 Output

 

A program to print Triangle of number:

 

Code:

 

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,n;

printf(“enter range of number:”);

scanf(“%d”,&n);

for(i=n;i>=0;i–)

{

for(j=1;j<=i;j++)

{

printf(“10”);

}

printf(“\n”);

}

getch();

}

 

Output:

 

3 Output

 

Happy coding.

 

 

 

 

 

 

Tags: , , , ,