Recent

Comments

Follow us on Facebook

Sunday 12 November 2017

Armstrong numbers

Write a program to print all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number.
For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
  • Source Code
#include<iostream>
using namespace std;

int main()
{
 int n,digit1,digit2,digit3;

 for(int i=1;i<=500;i++)
 {
  digit1=i/100;
  digit2=i/10 - digit1*10;
  digit3=i%10;

  if(digit1*digit1*digit1 + digit2*digit2*digit2 + digit3*digit3*digit3 == i)
   cout<<i<<endl;
 }

 
 return 0;
}

0 on: "Armstrong numbers"

Write a program, that takes 16-Elements in Two-Dimensional-Array that has 4 rows & 4 columns, then display the diagonal of Matrix.

Write a program, that takes 16-Elements in Two-Dimensional-Array that has 4 rows & 4 columns, then display the diagonal of Matrix. ...

propeller ads

PropellerAds