Pattern in C language 2

Pattern in c language 
Number patterns in C

 P2.1-program to print following pattern

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

code-

#include<Stdio.h>

void main()

{

int i, j;

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

{

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

printf("%d ",j);

printf("\n");                                                                for loop

}

}

P2.2-program to print following pattern

   1
   2 2 
   3 3 3
   4 4 4 4
   5 5 5 5 5 
code-
#include<stdio.h>
void main()
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
printf("%d ",i);
printf("\n");
}
}

P2.2-program to print following pattern

*
* *
* * *
* * * *
* * * * 
code
#include<stdio.h>

void main()
{ int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
printf("* ");
printf("\n");
}
}
P2.4-program to print following pattern
                A
A B
A B C
A B C D
A B C D E
code-
#include<Stdio.h>
void main()
{

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


P2.5-program to print following pattern
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
code-
#include<Stdio.h>
void main()
{
int i, j;
for(i=0;i<=4;i++)
{
for(j=0;j<=i;j++)
printf("%d ",5-j);
printf("\n");
}
}


P2.5-program to print following pattern
1
12
123
1234
12345
code-
#include<Stdio.h>
void main()
{ int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
printf("%d ",j);
printf("\n");
}
}

P2.6-program to print following pattern
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

code-
#include<Stdio.h>
void main()
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
printf("%d ",j);
printf("\n");
}
}

P2.7-program to print following pattern
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
code-
#include<stdio.h>
void main()
{

int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
printf("* ");
printf("\n");
}
}
P2.8-program to print following pattern

A B C D E
A B C D E
A B C D E
A B C D E
A B C D E
code-
#include<Stdio.h>
void main()
{

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

P2.9-program to print following pattern
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
code-
#include<stdio.h>
void main()
{
int i,j;
for(i=1;i<=5;i++) 
{
for(j=1;j<=i;j++)
printf("%d",j%2);
printf("\n");
}
}
P2.10-program to print following pattern
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
code-
#include<stdio.h>
void main()
{
int i,j;
for(i=5;i>=1;i--) 
{
for(j=i;j>=1;j--)
printf("%d ",j);
printf("\n");
    }
}

Comments

Popular posts from this blog

CYBER SECURITY & CRACKING PASSWORDS

"The Dark Side of Social Media: How It Fuels Digital Addiction and Impacts Mental Health"

Online Platforms to Learn Coding