Posts

Showing posts with the label armstrong c

c program to find armstrong number

Image
c program to find armstrong number armstrong number means the sum of cubic digits of any number is equal to that number. for eg. any number is 153 then 1*1*1+5*5*5+3*3*3=153 so 153 is armstrong number. #include <stdio.h>   int power(int, int);   int main() {    int n, sum = 0, temp, remainder, digits = 0;      printf("Input an integer\n");    scanf("%d", &n);      temp = n;    // Count number of digits    while (temp != 0) {       digits++;       temp = temp/10;    }        temp = n;        while (temp != 0) {       remainder = temp%10;       sum = sum + power(remainder, digits);       temp = temp/10;    }      if (n == sum)       printf("%d is an Arm...