answersLogoWhite

0


Best Answer

/*Program to find Armstrong number between 1 to N*/

int main() {

int n = 0, remainder, sum = 0, i = 0, noDigits = 0, isArm = 0;

char ch[60] = {0};

printf("Find the Arm Strong Numbers between 1 to N");

scanf("%d", &n);

for(i = 1; i<n; i++)

{

isArm = i;

itoa(isArm, ch, 10);

noDigits = strlen(ch);

while(isArm)

{

remainder = isArm%10;

isArm=isArm/10;

sum= sum+pow(remainder, noDigits);

}

if(sum == i)

printf("\nArm Strong Nos are %d\n", i);

sum = noDigits = 0;

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

if the sum of the cubic value of each digit of a number is equal to the original number , then that particular number is an Armstrong number :-)

Actually, Armstrong numbers are the sum of their own digits to the power of the number of digits.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include(stdio.h)

#include(conio.h)

int main( )

{

int no, temp, rem, sum;

clrscr( );

printf("Armstrong numbers between 1 and 1000 are:\n");

for(no=1; no<=1000; no++)

{

temp=no;

sum=0;

while(temp>0)

{

rem=temp%10;

sum=sum+(rem*rem*rem);

temp=temp/10;

}

if(no==sum)

printf("\n%d", no);

}

getch( );

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

#include <iostream>

#include <math.h> // for std::pow()

unsigned int get_length(unsigned int num,const unsigned int base=10)

{

unsigned int len=1;

while(num && (num/=base))

++len;

return( len );

}

bool is_armstrong(const unsigned int num,const unsigned int base=10)

{

unsigned int len=get_length(num,base);

unsigned int sum=0;

unsigned int tmp=num;

while(tmp)

{

sum+=(unsigned int)std::pow((double)(tmp%base),(double)len);

tmp/=base;

}

return(num==sum);

}

int main()

{

std::cout << "Armstrong series (base 10):";

for(unsigned int num=0; num<=0xffffffff; ++num)

if(is_armstrong(num))

std::cout << " " << num;

std::cout << std::endl;

return(0);

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

You will need:

  • A computer
  • The computer language you will write in
  • The understanding of Armstrong Numbers
  • The number you want to find
  • How the number is presented to the program as the input
  • Where the output of the program should go
  • How to put all together as a program
This answer is:
User Avatar

User Avatar

Wiki User

12y ago

class armstrong

{

public void m()

{

int s,d,i,n;

for(i=1;i<=500;i++)

{

s=0;

n=i;

while(n>0)

{

d=n%10;

s=s+(d*d*d);

n=n/10;

}

if(s==i)

{

System.out.println(s+" ");

}

}

}

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

/*Program to check for armstrong number */

#include<stdio.h>

#include<math.h>

main()

{

int a, b, z,x, sum = 0;

printf("enter the number to check if it is armstrong number\n");

scanf("%d", &x);

z=x;

if ((z >= 100) && (z <= 900))

{

a = z % 10;

z = z / 10;

b = z % 10;

z = z / 10;

sum = pow(a, 3) + pow(b, 3) + pow(z, 3);

if (x== sum)

printf("a is an armstrong number.\n");

else

printf("not a armstrong number\n");

}

else

printf("armstrong number must be of three digit\n");

}

/*posted by prabhat5052@gmail.com*/

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

class ArmstrongNumbers{

public static void main(String[] args){

int num, temp, digit1, digit2, digit3;

System.out.println("Armstrong numbers between 1 and 500: ");

num = 1;

while (num <= 1000){

digit1 = num - ((number / 10) * 10);

digit2 = (num / 10) - ((number / 100) * 10);

digit3 = (num / 100) - ((number / 1000) * 10);

temp = (digit1*digit1*digit1) + (digit2*digit2*digit2) + (digit3*digit3*digit3);

if (temp == num){

System.out.println("Armstrong Number:"+ temp);

}

num++;

}

}

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

m,kj,kh,kj

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program to print Armstrong numbers between 1 and 100 using for loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i &lt;= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Write a c program to print the 100 to 1 nos?

Write a c program to print the 100 to 1 nos


Write a program to print even and odd numbers in between 1 to 10?

for (int i = 2; i < 10; i ++) printf("%d\n", i); You did say even and odd numbers between 1 and 10. That's allnumbers between 1 and 10.


C program to print numbers 1 to n?

how do we use loops in c plus plus programing and what are basic differences between do,for and while loop


Write a C Program to print sum of squares of odd numbers?

#include


What BASIC program can compute and display all prime numbers from 1 to 40?

PRINT 2,3,5,7,11,13,17,19,23,29,31,37


How can you print a list of your SIM card numbers?

Install your phone software program and download the list to your PC then print. Your phone program can be downloaded from your phone maker web site if it did not come with your phone package.


How do you write a program to print numbers from star one and next line star two in php?

Try the triangle program on a search engine. Replace numbers with stars and that should do the trick


Program to print all the even numbers of an array in visual basic?

find even number in array


How do you write a Qbasic program to display these Numbers-0112358132134?

you do this 10 print "0112358132134" use the whole of the thing