
Jayden H. answered 07/13/15
Tutor
5
(1)
I am patient and love helping people learn.
There are likely numerous ways of doing this. I would create a string variable and then use concatenation in a for loop to create a string of m characters. Once the string variable is the right length, print it n number of times.
Here is a description of the code:
Remember to include the libraries needed, "string" and "iostream" at least.
main function
initiate variables:
int type for n and m, also some other int type variable for the for loops
string type variable to hold the "#"
Prompt the user for the n value
User input n value
Prompt the user for the m value
User inputs m value
Construct for loop to loop through n times
concatenate string variable. I would suggest the simple code: string variable = '#' + string variable
construct for loop to output string variable m times
Output string variable
That should work. The main function does not need to return a value (return 0).
I hope this helps Izzy.