Printing asterisk

How do i print asterisk ?

Page 1 of 1

2 Replies - 6955 Views - Last Post: 06 May 2010 - 04:29 PM Rate Topic: -----

#1 ultimatejester  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-May 10

Printing asterisk

Posted 06 May 2010 - 03:42 PM

How do I print asterisks?
A program is required that prompts the user for a number. The program will then print a series of asterisks to represent the number. If the user enters a number less than 1, the program stops. For example:

Enter a number: 5
*****
Enter a number: 3
***
Enter a number: 9
*********
Enter a number: 0
Is This A Good Question/Topic? 0
  • +

Replies To: Printing asterisk

#2 citus  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 140
  • Joined: 28-March 10

Re: Printing asterisk

Posted 06 May 2010 - 03:45 PM

If you are using c++ try using std::cout
Was This Post Helpful? 0
  • +
  • -

#3 BlueMelon  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: Printing asterisk

Posted 06 May 2010 - 04:29 PM

#include <iostream>
using namespace std;

int main()
{

int number;

cout<<"Enter a Number: ";
cin >> number;

for (int i(0); i<number;i++)
{
	cout << "*";
}

cout << "\n\n Press any key to continue...";
getchar();
return 0;
}




If user enters a letter it exits.

This post has been edited by BlueMelon: 06 May 2010 - 04:29 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1