Write a program to print the pattern

55555
44444
33333
22222
11111


Write a C program to print the pattern. or Write a program to print the pattern in C.

Code:

#include<stdio.h>
int main()
{
  printf("Enter the row and column size:");

  int row_size,out,in,p;

  scanf("%d",&row_size);
  for(out=row_size;out>=1;out--)
  {
   for(in=1;in<=row_size;in++)
    printf("%d",out);

        printf("\n");

  }
}


Input/Output:
Enter the row and column size:5
55555
44444
33333
22222
11111

Write a C++ program to print the pattern. or Write a program to print the pattern in C++.

Code:

#include<iostream>
using namespace std;
int main()
{
  cout<<"Enter the row and column size:";
  int row_size,out,in,p;
  cin>>row_size;
  for(out=row_size;out>=1;out--)
  {
   for(in=1;in<=row_size;in++)
    cout<<out;

        cout<<"\n";

  }
}

Input/Output:
Enter the row and column size:6
666666
555555
444444
333333
222222
111111


Write a JAVA program to print the pattern. or Write a program to print the pattern in Java.

Code:

import java.util.Scanner;
public class p10 {

public static void main(String[] args) {

Scanner cs=new Scanner(System.in);
System.out.println("Enter the row and column size:");
int row_size,out,in;
  row_size=cs.nextInt();
  for(out=row_size;out>=1;out--)
  {
   for(in=1;in<=row_size;in++)
    System.out.print(out);

        System.out.println();

  }
cs.close();
}
}

Input/Output:
Enter the row and column size:
4
4444
3333
2222
1111

Write a PYTHON to print the pattern. or Write a program to print the pattern  in Python.

Code:

row_size = int(input("Enter the row and column size:"))
for out in range(row_size0, -1):
    for i in range(0row_size):
        print(outend="")
    print("\r")


Input/Output:
Enter the row and column size:
5
55555
44444
33333
22222
11111

Post a Comment

0 Comments