Pattern 1:-
Example => input : 4
output : ****
****
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}
Pattern 2:-
Example => input : 4
output :
* * * *
* * *
* *
*
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}
Pattern 3:-
Example => input : 4
output :
*
* *
* * *
* * * *
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}
Pattern 4:-
Pattern Programe
Example => input : 3
output :
*
***
*****
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=n-i;j>1;j--){
cout<<" ";
}
for(int j=0;j<=i;j++){
cout<<"*"<<" ";
}
for(int j=1;j<=i;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}
Comments