Armstrong number

how to further write code for printing true and false while considering the given function.and also how to check it for a 4 digit no?

hello @lovely see this :
https://ide.codingblocks.com/s/363766
but your code is not producing the correct answer .
please go through your logic again and if you still have any doubt you can ask here .

https://ide.codingblocks.com/s/363766
but this code is not producing true input when armstrong no is given.where i am getting wrong?

@lovely this is what i was saying .
this is because you are comparing and performing on n only .
so at the end you n is changed .
you have to store that n in some other variable first then only you can check .

see this :
https://ide.codingblocks.com/s/363766

ya its working now but 2 test cases getting failed .and showing as did u check for neagtive numbers.
so i generalised my code for any n digit number and also updated for negative inputs.
https://ide.codingblocks.com/s/364088 can u please tell why it is getting wrong,

sorry i tried it again now it worked finally so need to check :innocent
:https://ide.codingblocks.com/s/364088?_ga=2.35482344.894386579.1603720019-1196712039.1561117512

HELLO @lovely what is the error it is giving now ?

no actually now its not giving any number .i later on generalised the code for n digits number,in that earlier i was getting some error but after some time, i got it corrected.

hey @lovely i have just checked your code and your code is passing every test case .
your code is correect .
Happy Learning !!

1 Like