I have some number:
int i = 43;
I need to divide this number in to two digits. For example - 43, to get a 4 and 3. Help me pls)
I have some number:
int i = 43;
I need to divide this number in to two digits. For example - 43, to get a 4 and 3. Help me pls)
Try using / and %
Algo will be:
1>divide the number by 10.
2>print the remainder or store it in an array.
3>assign the quotient as the original number and loop steps 1-2-3 till quotient it less than 10
4>print the last digit or store it.
Now you should have each digit.
#include<iostream.h>
main()
{
int t,n;
cout<<"Enter a number:";
cin>>n;
t=n%10;
n=n/10;
cout<<"is:"<<n;
cout<<"is:"<<t;
}
Thank 4 the help!