0% found this document useful (0 votes)
12 views3 pages

Pattern Day4

Programing pattern

Uploaded by

cujohozu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Pattern Day4

Programing pattern

Uploaded by

cujohozu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Write a c program for the following pattern

1 2 3 4 5

0 3 4 5 6

0 0 5 6 7

0 0 0 7 8

0 0 0 0 9

#include <stdio.h>

int main() {
// Write C code here
int n,count=1;
scanf("%d",&n);

for(int i=1;i<=n;i++)
{ count=i*2-1;
for(int j=1;j<=i-1;j++)
{
printf("0 ");
}

for(int k=1;k<=n-i+1;k++)
{
printf("%d ",count++);
}

printf("\n");
}

return 0;
}
===================================================================================
===================================================================================
==========
Write a c program for the following pattern

1 * 2

1 * 2 * 3

1 * 2 * 3 * 4

#include <stdio.h>

int main() {
// Write C code here
int n,count=1,odd=1;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{ count=1;

for(int j=1;j<=odd;j++)
{
if((j)%2==0)
{
printf("* ");
}
else printf("%d ",count++);
}
odd=odd+2;

printf("\n");
}

return 0;
}
===================================================================================
===================================================================================
==========
3)Write a c program to print the pattern

2 3

4 5 6

7 8 9 10

11 12 13

14 15

16

#include <stdio.h>

int main() {
// Write C code here
int n,count=1;
scanf("%d",&n);

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

for(int i=n-1;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
printf("%3d",count++);
}
printf("\n");
}

return 0;
}
===================================================================================
===================================================================================
==========
1 2 3 4 5

2 3 4 5 1

3 4 5 1 2

4 5 1 2 3

5 1 2 3 4

#include <stdio.h>

int main() {
// Write C code here
int n,count=1,count2=1;
scanf("%d",&n);

for(int i=1;i<=n;i++)
{ count=i;
count2=1;
for(int j=1;j<=n-i+1;j++)
{
printf("%d ",count++);
}
for(int k=1;k<=i-1;k++)
{
printf("%d ",count2++);
}
printf("\n");
}
return 0;
}

You might also like