Hi all
my teacher asked me two things
first thing
he wants from me write program allow the user to enter 4 a digits numbers
and output will be like this
Enter a 4 digits numbers
9876
6
7
8
9
Press any key to continue
and this code for program is correct100%
Code:
#include <iostream>
using namespace std;
int main()
{
int n , d , i;
cout << "Enter a 4 digits numbers\n";
cin >> n;
for(i=1; i<=4; i++)
{
d= n % 10;
n = n / 10;
cout << d <<endl;
}
return 0;
}
but where the problem ?
the problem in second question he wants write other program allow the user to enter any number he wants for example if he entered 987654 out will be like this
4
5
6
7
8
9
Press any key to continue
not just 4 digits but every digits the user wants it
I tried more than 20 times but all my tries failed.