# printing the pattern

• March 10th, 2014, 12:03 PM
krishna5001
printing the pattern
i want to know how to print this type of pattern when a name is given ???
example:

name given TEJA

Attachment 2770
• March 10th, 2014, 12:18 PM
GregBrannon
Re: printing the pattern
Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

This is an interesting twist on ascii art that I haven't seen before. In general, it is accomplished with for loops, probably at least 2 loops - one nested in the other - but there may be helper loops in addition to those. You'll need to do some math up front. Determine how many lines there are (the outside loop), how many columns there are (the inside loop), and in this case you'll need to think about and calculate spacing for the spokes. When you've gotten that figured out just using pencil and paper for the example name you've given, then consider what might happen if the name input is a five-letter (or some odd number) name instead of an even number. How will that change the resulting pattern and the math involved?

After you have that roughed out, start coding. You might start by simply coding the pattern you've shown us using 4 asterisks as a constant name. Once you have that figured out, then move to substituting user input characters for the string of asterisks.

Good luck!
• March 10th, 2014, 12:20 PM
Norm
Re: printing the pattern
Start by taking a piece of graph paper and drawing the pattern on it.
Then look at what is printed on each line starting at the top.
The code will need to print a line for each line on the graph paper.
For each line that is to be printed, work out the spacing between each letter that is printed on that line.
• March 10th, 2014, 01:15 PM
jashburn
Re: printing the pattern
+1 on starting with pencil and graph/squared paper. I would've done the same myself. If you don't have such paper at hand, you can go to Squared paper to download and print it yourself.

For good results, I'd also recommend using a monospaced font such as Courier, Courier New and Lucida Console on the display console (in your IDE or Windows command prompt) so that you get consistent spacing between letters.