problem with loop

Hey I'm really new to c++ and am currently frustrated and at wits end on how to print a character beside each other instead of below it after asking input from user. This is what i got so far ---


#include <iostream>

using namespace std;

int main() {

int posNumber;
char letter;

cout << "Please enter a positive integer";
cin >> posNumber;

cout << "Please enter a character";
cin >> letter;

for (int i = 1; i <= posNumber; i++)

{
cout << letter <<
endl;
}


system("PAUSE");
return 0;
}

//unfortunately this prints the character entered below each other rather than beside. Any tips or help would help me immensely and prevent me from loosing my mind

~~ Cheers Nut420x
Remove the endl.
I already tried that and it won't work it shows an error when i try and compile

it gives me an error message of this expected `;' before '}' token

any other ideas?
Does it look like this?
1
2
3
{
cout << letter;
}
Awesome thank-you finally works ... Something so simple yet a tiny little mistake
Last edited on
you wouldn't also know how for this program. To use a new variable to count up to 10 characters and then start printing on a new line, but does not require that you add loops. you do have to set the count variable back to zero when print out a newline character. I'm having difficulty incorporating the count variable. I understand if you do not want to spend anymore time working on this. Thank-you for the help you did provide

so it looks something like this for every integer entered over 10 it prints on the next line

please enter a positive integer: 32
please enter a character: +

++++++++++
++++++++++
++++++++++
++

Last edited on
Topic archived. No new replies allowed.