1. ## Help for beginner please!

Can someone please show me how I can ask a user for numbers one at a time i.e.:
1
2
3
4
and then turn that number into one number of 1234. I have been trying everything that I can think of and can't figure it out. Please help!

Steph

Code:
```#include<iostream.h>

void showvalues(int[]);

void main ()
{

int num1[5], num2[5];

cout<< "enter number" <<endl;
for (int count = 0; count < 5; count++)
cin >> num1[count];

showvalues(num1);
cout << endl;

cout<< "enter number" <<endl;
for (int count1 = 0; count1 < 5; count1++)
cin >> num2[count1];

showvalues(num2);
cout << endl;

}
void showvalues(int nums[])
{
for(int index = 0; index < 5; index++)
cout <<nums[index] << "";

}```

2. Show us what you've done so far (i.e. post some code).

3. You only need cin and cout. If you haven't used them then you really need to learn more. That's all I will tell you. Also, post your code (if you have any).

- SirCrono6

4. Originally posted by sflyers
This is what i last had.......I know it's completely wrong though. I didn't want you to think I wanted you to write it for me just steer me in the right direction.

Code:
```#include<iostream.h>

void main (void)
{

int time[5], time2[5];
int time3;
cout<< "enter number" <<endl;
for (int count = 0; count < 5; count++)
cin >> time[count];
cout << "nums:";
for(count=0; count <5;count++)
cout<< "" <<time[count];
cout <<endl;
cout<< "enter number" <<endl;

for (int count1 = 0; count1 < 5; count1++)
cin >> time2[count1];
cout << "nums:";
for(count1=0; count1 <5;count1++)
cout<< "" <<time2[count1];
cout <<endl;

cout << "the sum of the numbers is" << endl;
time3 = time[count] + time2[count1];
cout <<time3;
cout << endl;

}```
#1) fix your formatting so it's easier to read
#2) fix your code so you don't have compiler errors
#3) where is the code to "combine" the 4 input numbers into 1 numnber?

5. As I said, cin and cout, not really any need for that function:

Code:
```#include <iostream> //Be standard, drop the .h

//using namespace std; or
//using std :: cout;
//using std :: endl;
//using std :: cin;

int main( void )
{
int Num1, Num2, Num3, Num4;
{
//Or
std :: cout << "Enter a number: " << std :: endl;
std :: cin >> Num1;
//Go through them all (before below)
cout << "You entered: " << Num1 << Num2 << Num3 << Num4;
}
//cin.get(); , system("PAUSE"); Whatever you pause with
return 0;
}```
Or the other one:

Code:
```std :: cout << "Enter four numbers: " << std :: endl;
std :: cin >> Num1 >> Num2 >> Num3 >> Num4;
std :: cout << Num1 << Num2 << Num3 << Num4;```
=/

- SirCrono6

6. Originally posted by SirCrono6
As I said, cin and cout, not really any need for that function: what function?

Code:
```    cout << "You entered: " << Num1 << Num2 << Num3 << Num4;
}```
And how does this cout command
Originally posted by sflyers
turn that number into one number?
It doesn't turn anything into anything, it simply outputs the values.

7. Thanks anyways.....I figured out what I needed there. I have other things to worry about now.

8. >What function

void showvalues(int nums[])

As for cout, it ouputs the value to make it appear as 1 number.

Code:
```Enter 4 numbers: 1 2 3 4
You entered: 1234```
Code:
```Enter a number: 1
Enter a number: 2
Enter a number: 3
Enter a number: 4
You entered: 1234```
By not going like this:

Code:
`cout << Num1 << " " << Num2 << " " << Num3 << " " << Num4;`
Which shows the numbers as:

Code:
```Enter 4 numbers: 1 2 3 4
You entered: 1 2 3 4```
Same with the other one. But I suppose they aren't actually 1 number, only 4 pushed together...

- SirCrono6

9. I did not want to just see it as one number, it needed to become one number. I needed to have the user make 2 different numbers, entering one digit at a time and be able to get the sum of the 2 formed numbers that were formed.

10. ok then you'd need to add another variable named total.

Code:
`total = num1 + nim2 + nim3 + num4;`
or if you dont want the sum, and you want the number of them all put together, then this might work.

Code:
`total = num1, num2, num3, num4;`
or it may also work like..

Code:
`total.assign(num1, num2, num3, num4);`
for the last one, total needs to be a string.

11. Originally posted by Aalmaron
or if you dont want the sum, and you want the number of them all put together, then this might work.

Code:
`total = num1, num2, num3, num4;`
That will not work. Perhaps what you are looking for is something along the lines of:
Code:
`total = 1000 * num1 + 100 * num2 + 10 * num3 + num4;`

12. wow that would work. i didnt think of that.

Popular pages Recent additions