Member Avatar

Write code to prompt the user to input a character and a number. Then print out the character that number of times. This is one of many questions I must answer, but it will help me get started on my code.

Post what you have done and we will see and correct. I won't do your homework.

Member Avatar

You're not doing my HW by answering that question. I can get it to prompt me to enter a character and the number. But not how to print that character that many times.

You're not doing my HW by answering that question. I can get it to prompt me to enter a character and the number. But not how to print that character that many times.

Ok. Here is the code.

#include <iostream>
int main() {
   int i;
   int number=1;
   char charachter;

   cout<<"Please enter a charachter: ";cin<<charachter;
   cout<<"\nPlease enter a number:  "; cin<<number;
   for(i=0; i<number+1; ++i)
      cout<<charachter;
   return 0;
}

zhelih - please go back and fix your OBO error.

Or are you trying to give TechBoy a wrong homework answer?