1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ksenya-84 [330]
3 years ago
7

So far we have worked on obtaining individual digits from 4 digits of 5 digit numbers. The added them to find the sum of digits.

However, now we know about the loop and we can remove the limit of having a specific number of digits. Write a program to print out all Armstrong numbers between 1 and n where n will be an user input. If the 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) In order to solve this problem we will implement the following function: sumDigitCube(): write a function sumDigitCube() that takes a positive integer as a parameter and returns the sum of cube of each digit of the number. Then in the main function, take an integer n as input and generate each number from 1 to n and call the sumDigitCube() function. Based on the returned result, compares it with the value of the generated number and take a decision and print the number if it is Armstrong number
Computers and Technology
1 answer:
Anna35 [415]3 years ago
6 0

Answer:

#include<stdio.h>

int sumDigitCube(int n);

int main(){

   int n, i;

   printf("Enter number: ");

   scanf("%d", &n);

printf("The Armstrong numbers are:" );

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

       if(sumDigitCube(i)==i){

           printf(" %d", i);

       }

   }

   printf("\n");

   return 0;

}

int sumDigitCube(int n){

   int s = 0;

   int digit;

   while(n>0){

       digit = n%10;

       s += digit * digit *digit;

       n = n/10;

   }

   return s;

}

Explanation:

You might be interested in
Question = 5 Which of these causes problems because it causes all words to have the same shape? ​
Sever21 [200]
Where’s the picture?? Send the picture I’m not tryna just get points I want to help but you didn’t upload a picture
5 0
3 years ago
if you love games played on facebook, such as farmville, what might be your motivation for playing games
castortr0y [4]

Plato users the answer is Social Interaction!

3 0
4 years ago
Which of the following statements is true according to the code?
mihalych1998 [28]

Answer:

The #intro style applies to all paragraphs.

Explanation:

It is a class

A class applyies to all with that name

5 0
4 years ago
Mary is searching for the New Years video that she saved on her laptop which file extension should Mary look for
Zepler [3.9K]

documents file on her laptop

8 0
3 years ago
Read 2 more answers
I.C.T
oee [108]

Soft and hard copies in my opinion

8 0
3 years ago
Read 2 more answers
Other questions:
  • Why is it important to match the latencies fo the older modules to the newer modules?
    14·1 answer
  • How do you think engel would feel about computers information systems and the internet?
    14·2 answers
  • Who invented autonomous cars? When I look it up it comes up as William Bertelsen but he invented the idea of hovering cars. Help
    8·1 answer
  • An art board on which text and graphics are pasted is known as a __?
    12·1 answer
  • 9.6 Code Practice<br> Instructions<br> 1<br> Declare a 4x 5 array called N<br><br> Please helppp
    9·1 answer
  • Which data type is 2.5?
    5·1 answer
  • porfavor no es una pregunta dificil, nisiquiera es de una tarea, hace poco mi computador windows 10 no recibia el sonido de mis
    9·1 answer
  • 1.Discuss the complexities of owning and sharing digital information.
    5·1 answer
  • How to look at things you previously applied to on handshake
    13·1 answer
  • What is the term for the action of Brazil imposing tariffs on US imports in response to the imposed tariffs by the U.S. on Brazi
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!