**Description:**

In
this program the we have to construct output in the pyramid shape manner

**Algorithm:**

Step 1: Start

Step2:
initialize the num,I,y, x=35

Step3: read
the num

Step4:perform
the loop operation

For(y=0;y<=num;y++)

Step5:Gotoxy(x,y+1)

Step6: perform
the loop operation for displaying digits towards the left and right

For(i=0-y;i<=y;i++)

Step7: print
abs(i);

Step8: x=x-2;

Step9: Stop

**Program:**

#include<stdio.h>

#include<conio.h>

void main()

{

int num,i,y,x=35;

clrscr();

printf("\nEnter the number to generate
the pyramid:\n");

scanf("%d",&num);

for(y=0;y<=num;y++)

{

/*(x-coordinate,y-coordinate)*/

gotoxy(x,y+1);

/*for displaying digits towards the left and
right of zero*/

for(i=0-y;i<=y;i++)

printf("%3d",abs(i));

x=x-3;

}

getch();

}

__Output:__
1.enter the number: 0

4 1 0 1

2 1 0 1
2

3 2 1 0 1 2 3

4 3 2 1 0 1 2
3 4

2.enter the number: 0

3 1 0 1

2 1 0 1 2

3 2
1 0 1 2 3

**The program is error free**

__Conclusion:__

__VIVA QUESATIONS:__
1) What
is the use of dot operator in structures ?

Ans: The use of dot(

**.**) operator to access the members of a structure independently. The dot operator connects a member with the structure variable.
2) Define
unions ?

Ans: A union is a data type in c
which allows the overlay of more than one variable in the same memory area.

## No comments:

## Post a Comment