Q. Write a C program to make the following number hash symbol pyramid C program as:
1 # 3 # 5
1 # 3 #
1 # 3
1 #
1
Ans.
/*c program for number hash symbol pyramid*/
#include<stdio.h>
int main()
{
int r,c,num=5,n,p;
n=num;
for(r=1; r<=num; r++,n--)
{
for(c=1,p=1; c<=n; c++)
{
if(c%2==0)
printf("# ");
else
{
printf("%d ",p);
p=p+2;
}
}
printf("\n");
}
getch();
return 0;
}
Related Program:
1. Number character pyramid as:
1 a
21 ba
321 cba
4321 dcba
54321 edcba
2. Number character pyramid as:
1
AB
123
ABCD
12345
3. Even-odd number star pyramid as:
1
*2
1*3
*2*4
1*3*5
4. Diagonal star zero pyramid as:
*000000
0*00000
00*0000
000*000
0000*00
00000*0
000000*
5. Nested hash star pyramid as:
#####*#####
####*#*#####
###*####*###
##*######*##
#*########*#
*##########*
6. Star zero nested pattern as:
*000*000*
0*00*00*0
00*0*0*00
7. Two type symbol pyramid as:
@
##
@@@
####
@@@@@
You might also like to read:
1. Big list of 98+ C pyramid programs
2. Latest user asking pyramid program list
1 # 3 # 5
1 # 3 #
1 # 3
1 #
1
Ans.
/*c program for number hash symbol pyramid*/
#include<stdio.h>
int main()
{
int r,c,num=5,n,p;
n=num;
for(r=1; r<=num; r++,n--)
{
for(c=1,p=1; c<=n; c++)
{
if(c%2==0)
printf("# ");
else
{
printf("%d ",p);
p=p+2;
}
}
printf("\n");
}
getch();
return 0;
}
/**************************************
The output of above number hash symbol pyramid C program would be:
***************************************/
Figure: Screen shot for number hash symbol pyramid C program |
Related Program:
1. Number character pyramid as:
1 a
21 ba
321 cba
4321 dcba
54321 edcba
2. Number character pyramid as:
1
AB
123
ABCD
12345
3. Even-odd number star pyramid as:
1
*2
1*3
*2*4
1*3*5
4. Diagonal star zero pyramid as:
*000000
0*00000
00*0000
000*000
0000*00
00000*0
000000*
5. Nested hash star pyramid as:
#####*#####
####*#*#####
###*####*###
##*######*##
#*########*#
*##########*
6. Star zero nested pattern as:
*000*000*
0*00*00*0
00*0*0*00
000***000
7. Two type symbol pyramid as:
@
##
@@@
####
@@@@@
You might also like to read:
1. Big list of 98+ C pyramid programs
2. Latest user asking pyramid program list
0 komentar:
Post a Comment