- 0
Notifications Mark All Read
- Login
- Get Prime
Coding Question-20
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
Notifications Mark All Read
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
#include
using namespace std;
void printPattern(int n){
int m = n*3;
int h = n/2;
int fh = (m-3)/2;
for(int i=1;i<=h;i++){
int s=(m-(fh*2))/3;
for(int i=1;i<=fh;i++){
cout<<'-';
}
for(int i=0;i<s;i++){
cout<<".|.";
}
for(int i=1;i<=fh;i++){
cout<<'-';
}
cout<<endl;
// break;
fh=fh-3;
}
int welh = (m-7)/2;
for(int i=0;i<welh;i++){
cout<<'-';
}
cout<<"WELCOME";
for(int i=0;i<welh;i++){
cout<<'-';
}
cout<<endl;
int second = 3;
for(int i =1;i<=h;i++){
for(int i=0;i<second;i++){
cout<<'-';
}
int s = (m-(second*2))/3;
for(int i=0;i<s;i++){
cout<<".|.";
}
for(int i=0;i<second;i++){
cout<<"-";
}
second+=3;
cout<<endl;
}
}
int main()
{
//it will accept odd numbers only
printPattern(5);
return 0;
}