0

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)

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by crioto
0

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.

0

#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;
}

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.