Input Number, Output Characters?

I need to write a program where the user inters a 5-digit number and the program outputs exclamation points corresponding to the digit. So, it should look something like this.

Input:
12546
Output:
1 !
2 !!
5 !!!!!
4 !!!!
2 !!!!!!

and displays question marks when the user enters something other than a number
Input:
14ab5
1 !
4 !!!!
a ?
b ?
5 !!!!!

I know this is pretty simple but I have no idea where to even start, so if someone could give me some pointers to guide me through that would be great! Thanks!

Update:
I figured out how to separate the digits of the number by using:
1
2
3
4
5
6
7
8
9
10
11
12
    cout<<"Enter a 4-digit number."<<endl;
    string digits; 
    cin>>digits;
    
    cout<<digits[0]<<endl;
    cout<<digits[1]<<endl;
    cout<<digits[2]<<endl;
    cout<<digits[3]<<endl; 
    cin.get();
    cin.get();
    cin.get(); 
    cin.get();


and that I can produce the characters by using:
1
2
for (int i=0; i<digits; i++){
            cout<<"!";


but I'm not sure how to put it all together... If someone could help me that would be much appreciated! Thanks!
Last edited on
There are similiar post a few hour ago, try to check on it
Thanks, LendraDwi! For some reason, though, I can't find the answer I'm looking for in any of the recent posts... Do you remember what the post was called? I have no idea what topic this would be under.
Create diagonal lines or something
Something like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <sstream>

int main()
{
    std::string input;
    std::cout<<"Enter number: ";
    std::cin>> input;

    for (unsigned i = 0; i < input.length(); i++)
    {
        std::stringstream ss;
        int num;

        ss << input[i];
        ss >> num;

        std::cout << input[i] << " ";

        if (ss.fail())
            std::cout << "?";


        for (int k=0; k < num; k++)
        {
            std::cout << "!";
        }
        std::cout << "\n";
    }
}
Topic archived. No new replies allowed.