Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- simple for loop program
- working
- 1.for loop is used for increasing the mid width for the inverted v structure and then decreased to get the v structure
- */
- #include <iostream.h>
- #include <conio.h>
- #include <stdio.h>
- //using namespace std;
- int main()
- {
- system("COLOR 4E");
- int max =10;
- int min=0;
- int mid,left;
- for(int mid=max,left=min;mid>=0;left++,mid-=2)
- {
- for(int k=0;k<=left;k++)
- printf(" ");
- printf("*");
- for(int time=0;time<10000000;time++);
- for(int k=0;k<=mid;k++)
- printf(" ");
- printf("*");
- printf("\n");
- for(int time=0;time<100000000;time++);
- }
- for(mid=max,left=max/2;left>=0;left--,mid+=2)
- {
- for(int k=0;k<=left;k++)
- printf(" ");
- printf("*");
- for(int time=0;time<100000000;time++);
- for(int k=0;k<=mid-10;k++)
- printf(" ");
- printf("*");
- printf("\n");
- for(int time=0;time<100000000;time++);
- }
- for(mid=max,left=min;mid>=0;left++,mid-=2)
- {
- for(int k=0;k<=left;k++)
- cout<<" ";
- cout<<"*";
- for(int k=0;k<=mid;k++)
- cout<<" ";
- cout<<"*"<<"\n";
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment