30 likes | 105 Views
Start. int driver,mode. int x=100,y=150,i. for (i=1;i<=6;i++). PREPARE A STAIRCASE BY USING THE RECTANGLE DRAWN IN SEQUENCE. bar(x,y,x+100,y+150). x=x+50 y=y+50. Output. stop. Start program. Define data type. EXPLAINATION.
E N D
Start int driver,mode int x=100,y=150,i for (i=1;i<=6;i++) PREPARE A STAIRCASE BY USING THE RECTANGLE DRAWN IN SEQUENCE bar(x,y,x+100,y+150) x=x+50 y=y+50 Output stop
Start program Define data type EXPLAINATION x and y= horizontal and vertical coordinates, Initialize the value of x and y, i= variable used to count no. of staircase i varies from 1 to 6 and In each step i varies by one Draw a filled rectangle on given position Increment in x and y by50 Display a staircase End of program
Program: /*program to draw a staircase by using the rectangle in sequence*/ #include<conio.h> /*header file included*/ #include<graphics.h> /*graphics header file included*/ void main() /*execution of program starts here*/ { /*starting braces*/ int driver,mode,x,y,i; /*data type defined that must be integer type varible*/ detectgraph(&driver,&mode); /*driver and modes are set*/ initgraph(&driver,&mode,"\\BGI"); /*graphic mode is initialized*/ setpalette(0,5); x=100;y=150; /*value of x and y are assigned*/ for(i=1;i<=6;++i) /*for loop is used to draw rectangle in sequence*/ { /*starting braces of for loop*/ bar(x,y,x+100,y+150); /*bar coordinates are defined*/ x=x+50;y=y+50; } /*ending braces of for loop*/ getch(); /*display o/p on screen*/ restorecrtmode(); /*restore the screen to the mode */ } /*ending braces*/