Our website is made possible by displaying online advertisements to our visitors.Please consider supporting us by disabling your ad blocker.
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Translate it in your own Language

Print this Job Post

Print Friendly and PDF

Tuesday, May 13, 2014

Armstrong number c program

Armstrong number c program: c programming code to check whether a number is armstrong or not. A number is armstrong if the sum of cubes of individual digits of a number is equal to the number itself. For example 371 is an armstrong number as 33 + 73 + 13 = 371. Some other armstrong numbers are: 0, 1, 153, 370, 407.

C programming code

#include <stdio.h>
void main()
   int num, sum = 0, temp, remainder;
   printf("Enter a number\n");
   temp = num;
   while( temp != 0 )
      remainder = temp%10;
      sum = sum + remainder*remainder*remainder;
      temp = temp/10;
   if ( num == sum )
      printf("Entered number is an armstrong number.\n");
      printf("Entered number is not an armstrong number.\n");

Output of this program.

No comments:

Post a Comment

Copyright @ CrackMNC 2014-2024
Divas Nikhra Theme by Crack MNC