That's not that hard - you really just need a for loop and the / and % operators.
For example, in 54321,
54321 / 10000 will be 5.
54321 % 10000 will be 4321.
4321 / 1000 will be 4.
4321 % 1000 will be 321.
321 / 100 will be 3.
321 % 100 will be 21.
21 / 10 will be 2.
21 % 10 will be 1.
1 / 1 will be 1.
1 % 1 will be 0.
Your approach will have to be slightly different because the order is reversed, but if you think a bit about it I am sure you will find out how it works.
@hanst99:
your tip helped me to solve Uzumaki's question in a nice way :)
@Uzumaki:
maybe this will also help you: N % 10 will give you the last digit of your number and N / 10 will cut it off, meaning turns 123 into 12.
and i used a do-while-loop besides for, % and /.
Guys I did how to show the digits now I want to implement the code that will show the triangle of these digits. I couldn't find the way to do that. Can you help me on that?
Guys it almost worked but there is a subtle error. For example I input number 12345. The program shows :
5
44
333
2222
1
But I want to make the program to show 5 numbers of 1 in the end. Here is my code can you check it?
I would suggest you to fix your indention, it's currently a bit hard to read your code ;)
There is something a bit weird in your code:
row<=a
The problem is, a keeps getting smaller in your code. With a 9 digit number, the last line would never get displayed. The same for numbers with more than 9 digits, and there is also a chance it happens with less digit numbers. Aside from that, it doesn't make too much sense in the first place to do it while rows is smaller than a :O