Output Pattern:
Enter the Value of n :5
1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
5*5*5*5*5
4*4*4*4
3*3*3
2*2
1
Code for above Pattern:
#include<iostream>
using namespace std;
int main()
{
int n=0,i=0,j=0,k=0;
cout<<"Enter the Value of n :";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=0;j<i;j++)
{
if(i==1)
{
cout<<i;
}
else
{
cout<<i;
if(j<(i-1))
{
cout<<"*";
}
}
}
cout<<endl;
}
for(i=n;i>0;i--)
{int t=(i-1);
for(j=i;j>0;j--)
{
if(i==1)
{
cout<<1;
}
else
{
cout<<i;
if(t>0)
{
cout<<"*";
}
t--;
}
}
cout<<endl;
}
}
Enter the Value of n :5
1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
5*5*5*5*5
4*4*4*4
3*3*3
2*2
1
Code for above Pattern:
#include<iostream>
using namespace std;
int main()
{
int n=0,i=0,j=0,k=0;
cout<<"Enter the Value of n :";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=0;j<i;j++)
{
if(i==1)
{
cout<<i;
}
else
{
cout<<i;
if(j<(i-1))
{
cout<<"*";
}
}
}
cout<<endl;
}
for(i=n;i>0;i--)
{int t=(i-1);
for(j=i;j>0;j--)
{
if(i==1)
{
cout<<1;
}
else
{
cout<<i;
if(t>0)
{
cout<<"*";
}
t--;
}
}
cout<<endl;
}
}
No comments:
Post a Comment
we are hear to discuss your queries ,so please feel free to ask any of your queries.