Question: Write a program that inputs a string and displays the characters of the string diagonally in a square. Note: Both the number of rows and

Write a program that inputs a string and displays the characters of the string diagonally in a square.

Note: Both the number of rows and the number of columns are equal to the length of the input string. There should be one space in-between the columns. Other than the characters of the input string, the display should be filled with * and ! as shown in the given examples.

Hint: There are various approaches. One approach of using a 2-levels-nested-loop is to go through each row (r) and print the content of each column (c) in the row (r). At each column, decide what content to print by comparing r and c.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!