C program to Display the Armstrong numbers between a Given range

Program to Display the Armstrong numbers in between a Given range

Armstrong number is an integer number. Armstrong Number is also called as Narcissistic number or Pluperfect digital invariant. Three digit Armstrong number must be equal to the sum of cubes of all digits of the 3 digit number. n-digits Armstrong number must be 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 are Armstrong numbersThe below given C program to Display the Armstrong numbers between a Given range (Two Intervals). Kindly check out the program to to Display the Armstrong numbers between a Given range (Two Intervals).


Program to Display Armstrong Numbers Between Two Intervals (Range)


  #include<stdio.h>
  int main(){
                 int numb,rem,sum=0,entr,nr,i,m=1,digits=0;
                 int initial,final;
                 clrscr();
                 printf("\n Enter the Initial range :");
                 scanf("%d",&initial);
                 printf("\n Enter the Final range   : ");
                 scanf("%d",&final);
                 printf("\n Armstrong numbers between the given range are: \n");
                 for(numb=initial; numb<=final; numb++){
                 entr = numb;
                 nr=numb;
                 while(nr>0){
                 nr = nr / 10;
                digits +=1;
                }
                nr=numb;
                while(nr!=0){
                rem = nr % 10;
                nr = nr / 10;
               for(i=1;i<=digits;i++){
               m = m*rem;
               }
               sum +=m;
               m=1;
               }
               if(sum == entr)
               printf("%d ",sum);
               sum=0;
               digits=0;
               }
               return 0;
    }


Sample output:

    Enter the Initial range : 100

    Enter the Final range   : 20000

    Armstrong numbers between the given range are:  1   153   370   371   407   1634   8208   9474 

 


Most Related Armstrong or not Programs in C


C program to check whether a number is Armstrong or not.

* Check a 3 digit number is armstrong or not using C program 

* C program to display Armstrong numbers between range.

* C program to display Armstrong numbers between 1 and 1000.

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

Bookmark and Share