Computer Science, asked by aishwaryasangade1, 10 months ago

Write a c++ program to print the following pattern.
Sample Input:

3

Sample Output:

3
44
555
6666
6666
555
44
3

Answers

Answered by manthanjotwani2005
6

Answer:

#include <iostream>

using namespace std;

int main()

{

int n=4,num=n-1;

for(int i=1;i<=n;i++)

{

for(int j=1;j<=i;j++)

cout<<num;

num++;

cout<<endl;

}

num–;

for(int i=n;i>=1;i–)

{

for(int j=1;j<=i;j++)

cout<<num;

num–;

cout<<endl;

}

return 0;

}

Answered by aminvishak
29

Answer:

#include<iostream>

using namespace std;

int main()

{

int n = 3,n1,i,j;

cin >> n1;

for(i=1;i<=n+1;i++)

{

for(j=1;j<=i;j++)

cout<<n1;

n1++;

cout<<endl;

}

n1--;

for(i=n+1;i>=1;i--)

{

for(j=1;j<=i;j++)

cout<<n1;

n1--;

cout<<endl;

}

}

Explanation: All test are passing

Similar questions