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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started