Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int i,j,k,n,ch;
- do{
- cout<<"\nMenu";
- cout<<"\n1. Square pattern";
- cout<<"\n2. Triangle pattern";
- cout<<"\n3. Diaginal pattern";
- cout<<"\n4. Reverse diaginal pattern";
- cout<<"\n5. Quit";
- cin>>ch;
- switch(ch)
- {
- case 1: a1:
- cout<<"\nEnter Size:";
- cin>>n;
- if(n>=1 && n<=9)
- {
- for(i=0;i<n;i++)
- {
- for(j=0;j<n;j++)
- { cout<<n; }
- cout<<"\n";
- }
- }
- else
- {
- cout<<"\nYour Size is Out of range!!";
- goto a1;}
- break;
- case 2:a2:
- cout<<"\nEnter Size:";
- cin>>n;
- if(n>=1 && n<=9)
- {
- for(i=0;i<n;i++)
- {
- for(j=0;j<=i;j++)
- { cout<<n; }
- }
- }
- else
- {
- cout<<"\nYour Size is Out of range!!";
- goto a2;}
- break;
- case 3:a3:
- cout<<"\nEnter Size:";
- cin>>n;
- if(n>=1 && n<=9)
- {
- for(i=0;i<n;i++)
- {
- for(j=0;j<i;j++)
- {
- cout<<"*";
- }
- cout<<n;
- for(j=i+1;j<n;j++)
- {
- cout<<"*";
- }
- cout<<"\n";
- }
- }
- else
- {
- cout<<"\nYour Size is Out of range!!";
- goto a3;}
- break;
- case 4:a4:
- cout<<"\nEnter Size:";
- cin>>n;
- if(n>=1 && n<=9)
- {
- for(i=0;i<n;i++)
- {
- for(j=1;j<n-i;j++)
- {
- cout<<"*";
- }
- cout<<n;
- for(j=0;j<i;j++)
- {
- cout<<"*";
- }
- cout<<"\n";
- }
- }
- else
- {
- cout<<"\nYour Size is Out of range!!";
- goto a4;}
- break;
- case 5:
- return 0;
- break;
- default: return 0;
- }
- }while(ch>0 && ch< 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement