Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions