+ 1

Why this program not show output ??(for armstrong number from 1 to 100)

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

17th Jun 2023, 12:36 PM
Harshita Tyagi
Harshita Tyagi - avatar
8 Respuestas
+ 3
#include <stdio.h> int main() { int i, n, num, d; for (i = 1; i <= 100; i++) { n = i; num = 0; while (n != 0) { d = n % 10; n = n / 10; num = num + (d * d * d); } if (i == num) printf("%d\n", i); } return 0; } your Programe having some indentation mistake
18th Jun 2023, 8:58 AM
Vaibhav
Vaibhav - avatar
+ 1
How
17th Jun 2023, 12:55 PM
Harshita Tyagi
Harshita Tyagi - avatar
+ 1
1 should've to print
17th Jun 2023, 12:56 PM
Harshita Tyagi
Harshita Tyagi - avatar
+ 1
I got it thanks 🙏🏻
17th Jun 2023, 12:59 PM
Harshita Tyagi
Harshita Tyagi - avatar
+ 1
Vaibhav thanks 🙏🏻
18th Jun 2023, 1:16 PM
Harshita Tyagi
Harshita Tyagi - avatar
0
Because i is never equal to num in your code on line 15
17th Jun 2023, 12:54 PM
Bishnu Chalise
Bishnu Chalise - avatar
0
Add the following line before line 15 and check output: printf("i = %d, num = %d", i, num);
17th Jun 2023, 12:56 PM
Bishnu Chalise
Bishnu Chalise - avatar
0
hmmm...idk,why is it doing that?
19th Jun 2023, 12:32 AM
Celest Goodrich
Celest Goodrich - avatar