040
Write a C Program to print the Following Pattern?
1
3 2 1
5 4 3 2 1
7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
#include <stdio.h>
void main ()
{
int n = 5; //size
int z = 1;
int i, j, k;
for (i = 1; i <= n; i++)
{
for (j = n - 1; j >= i; j--)
{
printf (" ");
}
for (k = 0; k < z; k++)
{
printf ("%d ", z - k);
}
z += 2;
printf ("\n");
}
}
041
Write a C Program to print the Following Pattern?
A
ABC
ABCDE
ABCDEFG
ABCDEFGHI
#include<stdio.h>
void main ()
{
int m = 1;
int p_height = 5;
int p_space = p_height - 1;
int i, j, k;
for (i = 0; i < p_height; i++)
{
for (j = p_space; j > i; j--)
{
printf (" ");
}
for (k = 0; k < m; k++)
{
printf ("%c", k + 65); //65 is the ASCII of 'A'
}
m += 2;
printf ("\n");
}
}
042
Write a C Program to print the Following Pattern?
A
CBA
EDCBA
GFEDCBA
IHGFEDCBA
#include<stdio.h>
void main ()
{
int n = 5; //size
int z = 0;
int i, j, k;
for (i = 0; i < n; i++)
{
for (j = n - 1; j > i; j--)
{
printf (" ");
}
for (k = 0; k <= z; k++)
{
printf ("%c", z - k + 65);
}
z += 2;
printf ("\n");
}
}
043
Write a C Program to print the Following Pattern?
0
101
21012
3210123
432101234
#include<stdio.h>
void main ()
{
int n = 5; //size
int z = 1, y = 1;
int i, j, k;
for (i = 0; i < n; i++)
{
for (j = n - 1; j > i; j--)
{
printf (" ");
}
for (k = 1; k <= z; k++)
{
printf ("%d", abs (k - y));
}
y++;
z += 2;
printf ("\n");
}
}
044
Write a C Program to print the Following Pattern?
A
BAB
CBABC
DCBABCD
EDCBABCDE
#include<stdio.h>
void main ()
{
int n = 5; //size
int z = 1, l = 1;
int i, j, k;
for (i = 0; i < 5; i++)
{
for (j = 4; j > i; j--)
{
printf (" ");
}
for (k = 1; k <= z; k++)
{
printf ("%c", abs(k - l) + 65);
}
l++;
z += 2;
printf ("\n");
}
}
045
Write a C Program to print the Following Pattern?
1
121
12321
1234321
#include<stdio.h>
void main ()
{
int n = 4; //size
int z = 1;
int i, j, k;
for (i = 1; i <= n; i++)
{
for (j = n - 1; j >= i; j--)
{
printf (" ");
}
for (k = i - 1; k >= -(i - 1); k--)
{
printf ("%d", i - abs (k));
}
z += 2;
printf ("\n");
}
}
046
Write a C Program to print the Following Pattern?
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
#include<stdio.h>
void main ()
{
int n = 4; //size
int z = 1;
int i, j, k;
for (i = 0; i <= n; i++)
{
for (j = n - 1; j >= i; j--)
{
printf (" ");
}
for (k = i; k >= -i; k--)
{
printf ("%c", i - abs (k) + 65);
}
z += 2;
printf ("\n");
}
}
047
Write a C Program to print the Following Pattern?
*********
*******
*****
***
*
#include<stdio.h>
int main ()
{
int i, j, rows;
/* Input rows to print from user */
printf ("Enter number of rows : ");
scanf ("%d", &rows); // example rows = 5
for (i = 1; i <= rows; i++)
{
/* Print leading spaces */
for (j = 1; j < i; j++)
printf (" ");
/* Print stars */
for (j = 1; j <= (rows * 2 - (2 * i - 1)); j++)
printf ("*");
/* Move to next line */
printf ("\n");
}
return 0;
}
048
Write a C Program to print the Following Pattern?
4444444
33333
222
1
#include<stdio.h>
void main ()
{
int width = 7;
int p_space = width / 2;
int p_height = width - p_space;
int i, j, k;
for (i = p_height; i >= 1; i--)
{
for (j = p_space; j >= i; j--)
printf (" ");
for (k = 1; k <= width; k++)
printf ("%d", i);
width -= 2;
printf ("\n");
}
}
049
Write a C Program to print the Following Pattern?
7777777
55555
333
1
#include<stdio.h>
void main ()
{
int width = 7;
int p_space = width / 2;
int p_height = width - p_space;
int i, j, k;
for (i = p_height; i >= 1; i--)
{
for (j = p_space; j >= i; j--)
printf (" ");
for (k = 1; k <= width; k++)
printf ("%d", width);
width -= 2;
printf ("\n");
}
}
.png)