Why this code showing 153 is not an Armstrong number?? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 9

Why this code showing 153 is not an Armstrong number??

https://code.sololearn.com/cJ7OpBB2BO0e/?ref=app

2nd Mar 2018, 7:38 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
3 Antworten
+ 9
I am not good at C and I only added floor to following part of code: result += floor(pow(remainder, n)); Then it will work each Armstrong numbers.
2nd Mar 2018, 3:44 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 13
result is coming 152 , not 153 //its happening for 3 digit no.'s [ 15 _ ] //for 151 , result is coming as 126 in place of 127 , 1 number less 👉 see last comment on your code , might the inputs in pow (_,_), need to be in double & U also need to type cast the returning value to int
2nd Mar 2018, 8:15 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 9
Thank you
2nd Mar 2018, 4:13 PM
Abhivarshini Maddala
Abhivarshini Maddala - avatar