C program to check a given number is Armstrong or not using function

C program to check a given number is Armstrong or not using function

This page has a C program to check a given number is Armstrong or not using function. The Armstrong is a number which belongs to integer. Armstrong Number is also known as Pluperfect digital invariant or Narcissistic number. In general, n-digits Armstrong number is equal to the sum of nth power of all digits of the n-digits number. For Example . . . 153 and 1634 are Armstrong numbers. That is, 1*1*1*+5*5*5+3*3*3 = 153,  1*1*1*1+6*6*6*6+3*3*3*3+4*4*4*4=1634 and so that the both two numbers are Armstrong numbers. The below given C program is used to check a given number is Armstrong or not using function. Kindly check out the program to check a given number is Armstrong or not using function. The program to check Armstrong or not can be written in many ways.

How will ask to check a given number is Armstrong or not using function

The question to find whether a Given Number is Armstrong Number or not using function can be asked as  1). Find out the Armstrong number using C program using function.  2). C program to verify whether the given number is Armstrong or not using function.  3). C program to find whether the given number is Armstrong or not using function.  4). C Program to check whether number is Armstrong or not using function.  5). C Program to check whether a number is Armstrong or not using function.  6). C program to check a given number is Armstrong number or not using function.  7). C Program to find entered number is Armstrong number or not  8). Program to find Armstrong or not using function.   9). Program to find Armstrong numbers using function.   10). Program to find a given number is Armstrong or not using function.   11). Program to find a number is Armstrong or not using function.  12). C program to check a number is Armstrong or not using function


Program to check any Armstrong number using function


   #include<stdio.h>
   int armstrong(int);
   int main(){
           int numb,sum,entr;
           clrscr();
           printf("\n Give an Integer number: \n");
           scanf("%d",&numb);
           entr = numb;
           sum = armstrong(numb);
           if(sum == entr)
           printf("\n The Number %d is Armstrong ",entr);
           else
           printf("\n The Number %d is not Armstrong Number",entr);
    getch();
    return 0;
   }

   int armstrong(int n){
           int nr, digits=0, i, rem, s=0, m=1;
           nr=n;
           while(nr>0){
           nr = nr / 10;
           digits +=1;
           }
           nr=n;
           while(nr!=0){
           rem = nr % 10;
           nr = nr / 10;
           for(i=1;i<=digits;i++){
           m = m*rem;
           }
           s +=m;
          m=1;
          }
          return(s);
         }


Sample output:


Give an Integer number:  153

The Number  153  is Armstrong

 

Give an Integer number:  6074  

The Number  6074  is not Armstrong Number 


About Er. T.Tharesh Kumar

I am a Professor and Head of Department of Computer Science in an Arts and Science College. I have designed this website to provide solved example programs of different categories for all the school and college going students to learn C language deeply, and to practice Interview based Multiple Choice (Objective Type) questions and answers.

Other Related C Programs :

* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Armstrong numbers can be checkd by C program

The Armstrong is an integer number, and it has no decimal point. It is clear that, the n-digits Armstrong number must be equal to the sum of nth power of all digits of the n-digits number. For Example . . .  the integer numbers such as 153 and 1634 are Armstrong numbers. The Armstrong numbers can be checkd as 1*1*1 + 5*5*5 + 3*3*3 = 153,  1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634. The Armstrong numbers can be checkd by the above C program.

Bookmark and Share