Computer Science, asked by swapandas7708, 1 month ago

Write a program to accept a character and the number of rows display that character in a
given number of rows

Character is @

Rows is 4

Sample output -

@@@@
@@@@
@@@@
@@@@


atrs7391: programming language?
swapandas7708: yes
Niasinip: did u know ajjubhai
Niasinip: amitbhai
swapandas7708: now who is that
swapandas7708: I just need the answer of my question thats it
atrs7391: I mean python java qbasic which one?
swapandas7708: java
atrs7391: ok wait i can help you
swapandas7708: I will appreciate it

Answers

Answered by atrs7391
0

Answer:

If you find any problems related to the program, feel free to comment me down, if it's alright please let me know too..

Attachments:
Answered by anindyaadhikari13
1

Required Answer:-

Question:

  • Write a program to accept a character and number of rows and display the character in a given number of rows.

Solution:

Here is your program. It is written in Java.

import java.util.*;

public class Pattern {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.print("Enter a character: ");

char ch=sc.next().charAt(0);

System.out.print("Enter the number of rows: ");

int n=sc.nextInt();

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

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

System.out.print(ch+" ");

System.out.println();

}

sc.close();

}

}

Explanation:

  • Ask the user to enter the character and number of rows. Now, create two nested loop that iterates n times. Inside the inner loop, print the character.

Output is attached.

Attachments:
Similar questions