Output Pattern:
Enter the value of N and initial_value(S):3 3
3
44
555
555
44
3
Enter the value of N and initial_value(S):4 3
3
44
555
6666
6666
555
44
3
Code for above Pattern:
#include<iostream>
using namespace std;
int main()
{
int n=0,i=0,j=0,k=0,s=0;
cout<<"Enter the value of N and initial_value(S):";
cin>>n>>s;
int ww=s;
for(i=1;i<=n;i++)
{
for(j=0;j<i;j++)
{
if(i==1)
{
cout<<s;
}
else
{
cout<<ww;
}
}
ww++;
cout<<endl;
}
int yy=(ww-1);
for(i=n;i>0;i--)
{
for(j=i;j>0;j--)
{
if(i==1)
{
cout<<s;
}
else
{
cout<<yy;
}
}
yy--;
cout<<endl;
}
}
Enter the value of N and initial_value(S):3 3
3
44
555
555
44
3
Enter the value of N and initial_value(S):4 3
3
44
555
6666
6666
555
44
3
Code for above Pattern:
#include<iostream>
using namespace std;
int main()
{
int n=0,i=0,j=0,k=0,s=0;
cout<<"Enter the value of N and initial_value(S):";
cin>>n>>s;
int ww=s;
for(i=1;i<=n;i++)
{
for(j=0;j<i;j++)
{
if(i==1)
{
cout<<s;
}
else
{
cout<<ww;
}
}
ww++;
cout<<endl;
}
int yy=(ww-1);
for(i=n;i>0;i--)
{
for(j=i;j>0;j--)
{
if(i==1)
{
cout<<s;
}
else
{
cout<<yy;
}
}
yy--;
cout<<endl;
}
}
No comments:
Post a Comment
we are hear to discuss your queries ,so please feel free to ask any of your queries.