Project please helpé

I have to make a program and I have absolutely no idea how to go with it. What is excepted of me is to have a entered number, become fragmented, and then resembled.

Ex. 1394--> 1 3 9 4 --> 1394

Any help is appreciated, I've been doing fairly well in the class just here I have no idea where to go.
Is it a problem if you store an input in char array? This makes it easy to access one digit at a time.
Last edited on
Thats just it, I'm not sure how to proceed. I'm hoping for something that would give

ex.

-Enter number to be fragmented and reassembled.
-2442
-2 4 4 2
-2442
What I meant is that you stated you need to operate on numbers, but splitting particular charactes in a string is easier for chars, even if they look like digits:
1
2
3
4
5
6
7
8
9
10
char input[80];
cout << "Enter number: ";
cin >> input;
for(int i = 0; i < 80; i++)
{
    if ( input[i] == 0 )
        break;
    cout << input[i] << ' ';
}
cout << endl << input << endl;


Of course, if the idea of the excercise is to practice operations on numbers, then my solution will earn you a big fail :).
For the cout and cin, it give me the error that they have no storage class or type specifier. For both the << and >> it says it needs a declaration. The for also needs a decleration.

So i'm still not sure if this is the type of thing I would need because it doesn't work. I've been trying in this course, except the teacher been explaning everything in french and I have yet to grasp most of the concepts. Any help really is appreaciated thought.
That's because it is not entire program - it is body of main function, and it is expected, that you include iostream header, as well as use using namespace std;.
Last edited on
Thank you, I finished the code now. If you see any errors it's appreciated if you comment. Thanks for the help up to now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int main() {
	char again = 'Y';
	while (again == 'y' || again == 'Y') 
  { 

char input[80];
cout << "Entre une nombre: ";
cin >> input;
for(int i = 0; i < 80; i++)
{
    if ( input[i] == 0 )
        break;
    cout << input[i] << ' ';
}
cout << endl << input << endl;


cout << "Encore? (y/n) " ;
cin >> again;
}

cout << "La fin du Program." << endl;
return 0;
}
Last edited on
Topic archived. No new replies allowed.