C program to find numbers whose sum of cubes of individual numbers is that number
March 7, 2020
Here is an implementation of while loop in C to find numbers whose sum of cubes of individual numbers is that number. You can go a step further and make it so that you accept value of i and n.
main(){ int i = 1, a, b, c, n = 1000; printf("\n Enter a number between 1 and 1000>> "); while(i > 0 && i < n){ a = (i % 10 * i % 10 * i % 10); b = (i/10 % 10 * i/10 % 10 * i/10 % 10); c = (i/100 % 10 * i/100 % 10 * i/100 % 10); if(a + b + c == i){ printf("\nSum of cubes of the individual digits of %d is %d itself [%d = %d + %d + %d]\n", i, i, i,a,b,c); } } }