C Program to Print rectangle using Special Symbols
#include
#include
int main()
{
int i, j;
for (i = 0; i
< 10; i++)
{
printf("\n");
for
(j = 0; j < 10; j++)
{
if (i == 0 || i == 9 || j == 0 || j == 9)
printf("▲");
else
printf("-");
}
}
return (0);
}
C Program to Print Largest Number Pyramid
#include
#include
int main()
{
int i, j;
char symbol =
'a';
int num;
int count =
1;
printf("enter the number of letters in pyramid ");
printf("(less than 26) : \n");
scanf("%d", &num);
for (i = 1; i
<= num; i++)
{
for
(j = 0; j <= (count / 2); j++)
{
printf("%c ", symbol++);
}
symbol
= symbol - 2;
for
(j = 0; j < (count / 2); j++)
{
printf("%c ", symbol--);
}
count
= count + 2;
symbol
= 'a';
printf("\n");
}
return (0);
}
Output
Enter the number of
Letters in Pyramid (less than 26): 13
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
A B C D E F E D C B A
A B C D E F G F E D C B A
A B C D E F G H G F E D C
B A
A B C D E F G H I H G F E
D C B A
A B C D E F G H I J I H G
F E D C B A
A B C D E F G H I J K J I
H G F E D C B A
A B C D E F G H I J K L K
J I H G F E D C B A
A B C D E F G H I J K L M
L K J I H G F E D C B A
C Program to Print the Double Pyramid Pattern
#include
#include
int main()
{
int i, j, k;
int blank =
0;
int lines =
6;
char symbol =
'a';
int temp;
int diff[7] =
{ 0, 1, 3, 5, 7, 9, 11 };
k = 0;
for (i =
lines; i >= 0; i--)
{
printf("\n");
symbol
= 'a';
for
(j = i; j >= 0; j--)
{
printf("%c\t", symbol++);
}
blank
= diff[k++];
for
(j = 0; j < blank; j++)
{
printf("\t");
}
symbol
= 'f' - (blank / 2);
if
(blank == 0)
{
temp = i - 1;
}
else
{
temp = i;
}
for
(j = 0; j <= temp; j++)
{
printf("%c\t", symbol--);
}
}
return (0);
}
Output
A B C D E F G F E D C B A
A B C D E F F
E D C B A
A B C D
E E D C B A
A B C
D D C B A
A B
C
C B A
A
B
B A
A
A
No comments:
Post a Comment