c program to check the number is armstrong or not

Solutions on MaxInterview for c program to check the number is armstrong or not by the best coders in the world

showing results for - "c program to check the number is armstrong or not"
Stefania
24 Jan 2017
1#include <stdio.h>
2int main() {
3    int num, originalNum, remainder, result = 0;
4    printf("Enter a three-digit integer: ");
5    scanf("%d", &num);
6    originalNum = num;
7
8    while (originalNum != 0) {
9       // remainder contains the last digit
10        remainder = originalNum % 10;
11        
12       result += remainder * remainder * remainder;
13        
14       // removing last digit from the orignal number
15       originalNum /= 10;
16    }
17
18    if (result == num)
19        printf("%d is an Armstrong number.", num);
20    else
21        printf("%d is not an Armstrong number.", num);
22
23    return 0;
24}
25
Gabriele
02 Jan 2018
1#include <stdio.h>
2#include <math.h>
3void main ()
4{
5    int n,t,r,c,s=0;
6    printf("Enter the number: ");
7    scanf("%d",&n);
8    t=n;
9
10        while(t!=0)
11        {
12            r=t%10;
13            c=pow(r,3);
14            s=s+c;
15            t=t/10;
16        }
17
18        if(s==n)
19            printf("Armstrong");
20        else
21            printf("Not Armstrong");
22}
23
Matteo
01 Jan 2019
1#include <stdio.h>
2#include <stdlib.h>
3#include <math.h>
4
5int cube(int a)
6{
7    int c;
8    c =  a*a*a;
9    return c;
10}
11
12int armnum(int *a)
13{
14    int x = *a, n = 0, rem, r = 0;
15    while (x != 0) {
16        x /= 10;
17        n++;
18    }
19    x = *a;
20    while (x != 0) {
21        rem = x % 10;
22        r += cube(rem);
23        x /= 10;
24    }
25    if(r == *a){
26        return 1;
27    }
28}
29
30int main()
31{
32    int a, y;
33    scanf("%d", &a);
34    y = armnum(&a);
35    if(y == 1){
36        printf("It is an Armstrong number.");
37    }
38    else{
39        printf("It is not an Armstrong number.");
40    }
41}
queries leading to this page
check armstrong number in ccheck whether a number is armstrong or not c programarmstrong number c programarmstrong number in c for any numberint c 3d0 2ca 2ctemp 3b int n 3d153 3b 2f 2fit is the number to check armstrong temp 3dn 3b while 28n 3e0 29 7b a 3dn 2510 3b n 3dn 2f10 3b c 3dc 2b 28a 2aa 2aa 29 3b 7d if 28temp 3d 3dc 29 system out println 28 22armstrong number 22 29 3b else system out println 28 22not armstrong number 22 29 3b 7dprogram to check armstrong number in cwrite a program to find armstrong number in cprogram simple c programs for armstrong numbercheck if a number is a armstrong carmstrong number simple program in chow to find armstrong number of 5 digit number in cwhat is a armstrong number in carmstrong number in c using for loopwrite a code to check whether the given number is armstrong e2 80 99s number or notprogram to find armstrong numberprograming armstrong nubers in cmultiset to check if number is armstrongwrite a c program to check whether a given number is an armstrong number or not how to get the series of armstrongarmstrong number program in c languaec program to find given number is armstrong or nothow to find armstrong number in cfind armstrong number in cc program to print whether a number is armstrong or notwrite a sample code to check whether the given number is an armstrong number or not program to print all armstrong numbers in cc code for armstrong numberarmstrong number in c explainedarmstrong seriesarmstrong number ccheck armstrong no in ccode to determine whether a number is an armstrong numberprogram to find given number is armstrong or not in cwrite a sample code to check whether the given number is an armstrong number or noarmstrong sequence in cexample of armstrong numberwrite a c program to find whether the given number is an armstrong number or notarmstrong number in c with explanationprogram to check given number is armstrong or not in camstrong without using looparmstrong number c codearmstrong number in c programizewrite a c program to check if the given number is armstrong or notarmstrong in cprint all armstrong number in cwap to check a given number is armstrong or not 3farmstrong program in cfour digit armstrong number c codearmstrong numbersarmstrong number in carmstrong example with even number in itcode to check armstrong numverc program for armstrongcheckarmstrong 28 29check whether the number is armstrong or not in cc program to find armstrong numberprogram to find 4 digit armstrong numberarmstrong series in cprogram to check armstrong string in ccheck for armstrong number in chow to solve armstrong number in c5 write a c program to check armstrong number c program to check armstrong numberarmstrong number of n digitscheck armstrong number or not in c algorithmc program to check armstrong number using functiongenerate armstrong number in carmstrong number algorithm in carmstrong number code in cwrite a c program to check if the given number is armstrong or not algorithm how to check a armstrong number in cwrite a c prog to check armstrong numberfinding a number is armstrong or not in csimple c program to check armstrong numberarmstrong number in c simple programwrite a c program armstrong numbercode for armstrong number in cwhat is armstrong number in cfind armstrong in c4 digit armstrong number in cc programming armstrong numberc check for armostrong numbers without pow functionarmstrong numbers in chow to check armstrong number in ca c program to check whether a number is armstrong number or notarmstrong no in carmstrong number logicarmstrong number examplehow to find amstrong numberc program to determine armstrong numberarmstrong number program in carmstrong number codearmstrong number find 4 digits 3fc program that determine if a number entered is armstrong or not armstrongc program armstrong numberarmstrong number using function in cc program to find armstrong number in a rangewrite a program to test whether an integer entered by the user is an armstrong number or not write a c program to find whether the given number is an armstrong number or not with algorithmarmstrong number function in cfind armstrong number chow to find a given no is armstronghow to calqulate armstron nubers cwhat is armstrong number logic cc program to check the number is armstrong or nothow to find armstrong numberprint armstrong number in carmstrong number logic in cc program for armstrong numbercheck the number is armstrong or not cwap to check whether the number is an armstrong number or not c armstrong numberhow to generate armstrong numbers in carmstrong coding in cc program to calculate armstrong numbertake n as input and check which ones are armstrong number using a function in the range 1 to n c program to check the number is armstrong or not