armstrong number in c

Solutions on MaxInterview for armstrong number in c by the best coders in the world

showing results for - "armstrong number in c"
Alexander
14 Sep 2018
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
Lyla
01 Jan 2017
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
Alexandre
08 Apr 2020
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}
Charlton
17 Aug 2018
1//Bismillahir Rahmanir Rahim
2#include <stdio.h>
3#include <math.h>
4
5int digit(int n, int count){
6    while( n != 0){
7        n/=10;
8        count++;
9    }
10    return count;
11}
12
13int main(){
14	    int n, rem, num, sum = 0, count = 0, digits;
15	    while(1){
16	        printf("Enter a number (type 0 to exit) : ");
17            scanf("%d", &n);
18            
19            if(n==0){
20                break;
21            }
22            digits = digit(n,count);
23           
24    		num=n;
25    		while(num != 0){
26    			rem = num % 10;
27    			sum += pow(rem,digits);
28    			num /= 10;
29    		
30    			}
31    		
32    		if(sum == n){
33    			printf("%d is an armstrong number!\n", n);
34    			sum = 0;
35    		}else{
36    			printf("%d is not an armstrong number!\n", n);
37    			sum = 0;
38    		}
39	
40	    }
41	    
42	return 0;
43}
queries leading to this page
how to find armstrong numberwhat is armstrong number logic carmstrong number of n digitshow to check a armstrong number in chow to solve armstrong number in cc program to find armstrong numberarmstrong number logic in carmstrong number program in cc program to calculate armstrong numberwrite a c program to find whether the given number is an armstrong number or notarmstrong number cwrite a sample code to check whether the given number is an armstrong number or not check armstrong number or not in c algorithmcheck if a number is a armstrong cprogram to find armstrong numberwrite a code to check whether the given number is armstrong e2 80 99s number or nota c program to check whether a number is armstrong number or notarmstrong number program in c languaehow to generate armstrong numbers in carmstrong coding in cgenerate armstrong number in cc program to check armstrong number using functionc program for armstrongc program to find armstrong number in a rangecode to determine whether a number is an armstrong numberc program to check the number is armstrong or notexample of armstrong numberprogram to check armstrong string in cc program that determine if a number entered is armstrong or not armstrongwrite a program to test whether an integer entered by the user is an armstrong number or not four digit armstrong number c codearmstrong number function in carmstrong number examplearmstrong in carmstrong number logicwrite a program to find armstrong number in carmstrong number find 4 digits 3farmstrong number c programarmstrong number in c for any numberarmstrong number simple program in carmstrong no in ccheck whether the number is armstrong or not in cc program to print whether a number is armstrong or notprogram to find given number is armstrong or not in ccode to check armstrong numverhow to find armstrong number in cc check for armostrong numbers without pow functionprogram to check given number is armstrong or not in carmstrong number in carmstrong sequence in c4 digit armstrong number in cc program for armstrong numbertake n as input and check which ones are armstrong number using a function in the range 1 to n how to check armstrong number in carmstrong numbersfinding a number is armstrong or not in cwap to check whether the number is an armstrong number or not armstrong number algorithm in c5 write a c program to check armstrong number find armstrong number cfind armstrong number in cc program armstrong numberprogram to print all armstrong numbers in ccheck whether a number is armstrong or not c programarmstrong number in c simple programprint armstrong number in carmstrong number in c programizewrite a sample code to check whether the given number is an armstrong number or noarmstrong series in cwrite a c program armstrong numbercheck the number is armstrong or not cmultiset to check if number is armstrongwhat is a armstrong number in cprograming armstrong nubers in carmstrong number code in cc code for armstrong numberarmstrong number in c with explanationhow to get the series of armstrongarmstrong number c codehow to find armstrong number of 5 digit number in cc program to find given number is armstrong or notc program to determine armstrong numbercheck armstrong no in cwrite a c program to check whether a given number is an armstrong number or not write a c program to check if the given number is armstrong or not algorithm program to check armstrong number in chow to find a given no is armstrongcheckarmstrong 28 29how to calqulate armstron nubers cint 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 7dwrite a c program to check if the given number is armstrong or notarmstrong number codec program to check armstrong numberwrite a c prog to check armstrong numberarmstrong number using function in carmstrong numbers in cc programming armstrong numbercode for armstrong number in cwap to check a given number is armstrong or not 3ffind armstrong in cprogram simple c programs for armstrong numberc armstrong numberwhat is armstrong number in chow to find amstrong numberarmstrong seriesarmstrong example with even number in itprogram to find 4 digit armstrong numberamstrong without using looparmstrong program in cwrite a c program to find whether the given number is an armstrong number or not with algorithmcheck armstrong number in ccheck for armstrong number in carmstrong number in c using for loopprint all armstrong number in carmstrong number in c explainedsimple c program to check armstrong numberarmstrong number in c