Thread: Change numbers to symbols

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    17

    Change numbers to symbols

    I am relatively new to this.
    I need help on how to change an output from a number into a
    chararcter such as an asterisk - *.
    The perosn would input a number and then my program would change that number into the amount of asterisks needed.
    for example:

    the number inputed is 5. then I want to output - *****

    any help would be appreciated

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    85
    pretty easy, try this:

    cin>>value;
    for(int i=0; i<value;i++)
    cout<<"*";

  3. #3
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522
    A loop is what you need:
    Code:
    int num, x;
    
    cout << "Enter number ";
    cin >> num;
    
    for( x = 0; x < num; x++)
         cout << '*';
    All spelling mistakes, syntatical errors and stupid comments are intentional.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generate Random Numbers and Assign to Days of Week
    By mms in forum C++ Programming
    Replies: 10
    Last Post: 05-04-2006, 01:51 AM
  2. read numbers from a file
    By haroonie in forum C Programming
    Replies: 5
    Last Post: 03-27-2005, 11:30 PM
  3. Program that prints numbers in columns
    By rayrayj52 in forum C++ Programming
    Replies: 12
    Last Post: 09-20-2004, 02:43 PM
  4. help with calculating change from a dollar
    By z.tron in forum C++ Programming
    Replies: 3
    Last Post: 09-13-2002, 03:58 PM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM