//a cpp program to form the letter H #include <iostream> using namespace std; int main() { cout <<"* *"<< endl; cout <<"* *"<< endl; cout <<"* *"<< endl; cout <<"* *"<< endl; cout <<"**********"<< endl; cout <<"* *"<< endl; cout <<"* *"<< endl; cout <<"* *"<< endl; cout <<"* *"<< endl; return 0; }
//using astericks to display triangle
#include<iostream.h> #include<conio.h> void main() { clrscr(); int w, y; for(w=0; w<5; w++) { for(y=0; y<=i; y++) { cout<<"* "; } cout<<"\n"; } getch(); }
#include<iostream> using namespace std; int main() { cout<<"\"Inverted Triangle Shape\"\n\n"; int w=6; for(int g=0;g<9;g++) { cout<<"*"; // Displaying asterisk here } cout<<endl; // endl is for new line for(int a=1;a<=3;a++) { for(int b=0;b<a;b++) { cout<<" "; // displaying space here } cout<<"*"; for(int c=1;c<w;c++) { cout<<" "; } cout<<"*"<<endl; w=w-2; } for(int e=1;e<=1;e++) { for(int f=4;f>=e;f--) { cout<<" "; } cout<<"*"; } return 0; }
#include<iostream> using namespace std; int main() { cout<<"\"Hollow Triangle Shape\"\n\n"; int z=1; for (int i=0; i<7; i++) { for (int j=7; j>i; j--) { cout<<" "; // displaying space here } cout<<"*"; // displaying asterisk here if (i!=0) { for (int k=1; k<=z; k++) { cout<<" "; } cout<<"*"; z+=2; } cout<<endl; // endl is for new line } for (int i=0; i<=z+1; i++) { cout<<"*"; } return 0; }
0 comments:
Post a Comment