P
Pixie
I need help with this program, if anyone can give input. I can think
of how to do it, but it is hard for me to put into the program.
I realize that I am trying to separate out a certain digit number into
its separate digits. For example, a single
number like 43 to be split into 4 and 3. and that 43 is of the decimal
system where the 4 belongs to the 10th and the 3 belongs to the unit
place, which essentially means that 4 is a multiple of 10 and 3 is a
multiple of 1. So I would need to divide them somehow. But how do I do
this with a five digit number? I assume it is the same way, but cannot
figure it out. Any guidance would be helpful. Thanks, Pixie.
The program is:
// digits.cpp
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int num;
cout << "Enter a five-digit number: ";
cin >> num;
/* write a statement to print the left-most digit of 5-digit number
*/
/* write a statement that changes num from a 5-digits to 4-digits
*/
/* write a statement to print the left-most digit of 4-digit number
*/
/* write a statement that changes num from a 4-digits to 3-digits
*/
/* write a statement to print the left-most digit of 3-digit number
*/
/* write a statement that changes num from a 3-digits to 2-digits
*/
/* write a statement to print the left-most digit of 2-digit number
*/
/* write a statement that changes num from a 2-digits to 1-digit
*/
cout << num << endl;
return 0;
}
of how to do it, but it is hard for me to put into the program.
I realize that I am trying to separate out a certain digit number into
its separate digits. For example, a single
number like 43 to be split into 4 and 3. and that 43 is of the decimal
system where the 4 belongs to the 10th and the 3 belongs to the unit
place, which essentially means that 4 is a multiple of 10 and 3 is a
multiple of 1. So I would need to divide them somehow. But how do I do
this with a five digit number? I assume it is the same way, but cannot
figure it out. Any guidance would be helpful. Thanks, Pixie.
The program is:
// digits.cpp
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int num;
cout << "Enter a five-digit number: ";
cin >> num;
/* write a statement to print the left-most digit of 5-digit number
*/
/* write a statement that changes num from a 5-digits to 4-digits
*/
/* write a statement to print the left-most digit of 4-digit number
*/
/* write a statement that changes num from a 4-digits to 3-digits
*/
/* write a statement to print the left-most digit of 3-digit number
*/
/* write a statement that changes num from a 3-digits to 2-digits
*/
/* write a statement to print the left-most digit of 2-digit number
*/
/* write a statement that changes num from a 2-digits to 1-digit
*/
cout << num << endl;
return 0;
}