8.27.2013

Reverse L-Shape Pyramid

Q. Write a C program to print the following Reverse L-Shape pyramid as:

*************
*
*
*
*
*
*
*


Ans.

/*c program for reverse L-shape pyramid*/
#include<stdio.h>
int main()
{
 int c;

C Star Triangle

Q. Write a C program to make the following star triangle as:

*
**
**
**
******

Ans.

/*c program for star triangle design*/
#include<stdio.h>
int main()
{
 int r,c,n;
 printf("*\n");

8.26.2013

Nested Star-Hash Pyramid

Q. Write a C program to print the following star-hash pyramid design:

#####*#####
####*#*####
###*###*###
##*#####*##
#*#######*#
*#########*

/**************************************************************
How To Make Above nested Pyramid C program
***************************************************************
So you can see, there are four types pyramid in above design as:

 #####      *         #####
 ####      *#   *      ####
 ###      *##   #*      ###
 ##      *###   ##*      ##
 #      *####   ###*      #
       *#####   ####* 

Hence, now it is easy to make these above pyramid program. So i recommended to make first above four pyramid program, after making these pyramid design, add these all pyramid in single C program and you are done. :) )
**************************************************************/

Ans.

/*c program for nested star-hash pyramid*/
#include<stdio.h>
int main()
{

8.25.2013

Binary Geometric Number Pyramid

Q. Write a C program to print the following binary geometric number pyramid as:

 1
 2 3
 4 5 6 7
 8 9 10 11 12 13 14 15
 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

or

 7
 14 15
 28 29 30 31
 56 57 58 59 60 61 62 63

[How to create : in above pyramid design, left hand side vertical left align elements are as 1, 2, 3, 4, 8 as geometric sequence numbers. And each these number increase to +1, till equal the binary number as 1, 2, 4, 8, 16 and so on.
]

Ans.

/*c program for generating geometric sequence of any number*/
#include<stdio.h>
int main()
{
 int num,n,r,c,rows,x=1;

8.23.2013

Number Triangle Design

Q. Write a C program to print the following number triangle or pyramid design as:

1
121
12321
1234321

Ans.

/*c program for number triangle design*/
#include<stdio.h>
int main()
{
 int num,r,c,z;
 printf("Enter any number : ");
 scanf("%d", &num);

Alternate Number-Star Pyramid

Q. Write a C program to print the following alternate number-star pyramid/triangle as:

1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1

Ans.

/*c program for alternate number-star pyramid*/
#include<stdio.h>
int main()
{
 int num,r,c,z=1,p,n;
 printf("Enter maximum number : ");
 scanf("%d", &num);

Number Triangle Design

Q. Write a C program to design the number triangle pyramid as:

1
121
1231
12341
123451

Ans.

/*c program for number triangle design*/
#include<stdio.h>
int main()
{
 int num,r,c,z;
 printf("Enter No. of rows : ");
 scanf("%d", &num);

Diagonal Star and Zero Rectangle

Q. Write a C program to print the following diagonal star and zero rectangle structure as:

*000000
0*00000
00*0000
000*000
0000*00
00000*0
000000*

Ans.

/*c program for diagonal star and zero rectangle*/
#include<stdio.h>
int main()
{
 int rows=7,r,c;

Vertical Continues Number Pyramid

Q. Write a C program to print the following vertical continues number pyramid as:

 1

 23
 4
 56
 7
 89
 10

Ans.

/*c program for vertical continues number pyramid*/
#include<stdio.h>
int main()
{
 int r,c,x,y;