Ques. Programming Pattern to Print  2*N  Number of rows for input Pattern?

3
44
555
6666
555
44
3

Code in C++

C/C++ Program to Print- 3 44 555 6666 6666 555 44 3

#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;
}

Please do comment the code in other languages :).

Code in Java –

Java Program to Print- 3 44 555 6666 6666 555 44 3

public class Pattern {

public static void main(String[] args) {
 
 int N=4;
 for(int i=1;i<=N;i++) {
 for(int j=1;j<=i;j++) System.out.print(i+2); System.out.println(); } for(int i=N-1;i>=1;i--) {
 for(int k=1;k<=i;k++) System.out.print(i+2);
 
 System.out.println();
 }
 }

}

For AMCAT Programming – Coding Questions Visit our AMCAT Previous Coding Dashboard 

Watch our all of our YouTube videos series below on AMCAT Pattern Printing preparation and you will be able to solve any AMCAT Pattern questions easily also, subscribe our Youtube Channel as well.

Video 1 –

Video – 2

Video – 3