i'm new to this program C++. write a program that reads an integer and breaks it into a sequence of individual digits. for example the input 16384 is displayed as 1 6 3 8 4.
please help me edit and add some code to this.
Thanks a lot.
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Enter a five-digit number: ";
cin >> number;
cout << number / 10000 << " ";
number = number % 10000;
cout << number / 1000 << " ";
number = number % 1000;
cout << number / 100 << " ";
number = number % 100;
cout << number / 10 << " ";
number = number % 10;
cout << number << endl;
return 0;
}
The character '\' is used as an escape character in string literals for characters not represented visually, like newline '\n' or carriage return '\r'.
You need to type "\\" to use backslashes or else it thinks you are using it as an escape character.