Member Avatar for Techboy1523

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.

Recommended Answers

All 5 Replies

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

Member Avatar for Techboy1523

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.