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
salantis [7]
2 years ago
7

I want to solve this question in C program, Please.

Computers and Technology
1 answer:
inn [45]2 years ago
4 0

Answer:

#include <stdio.h>

#include <math.h>

int is_armstrong(int n) {

int cubedSum = 0;

int r = n;

while (r) {

         cubedSum += (int)pow(r % 10, 3);

          r = r / 10;

}

return cubedSum == n;

}

int stack_count(int n) {

int sum = 0;

while (n) {

         sum += n % 10;

         n = n / 10;

}

return sum;

}

int is_magical(int n) {

while (n > 9) {  

 n = stack_count(n);

 printf("%d ", n);

}

return n == 1;

}

int main()

{

int input = 0;

int isMagical, isArmstrong;

while (true) {

 printf("Enter a number: ");

 scanf_s("%d", &input, sizeof(int));

 if (input == -1) break;

 isArmstrong = is_armstrong(input);

 isMagical = is_magical(input);  

 if (isArmstrong && isMagical) {

  printf("%d is both an armstrong and a magical number.\n", input);

 } else if (isArmstrong) {

  printf("%d is an armstrong number\n", input);

 } else if (isMagical) {

  printf("%d is a magical number\n", input);

 } else {

  printf("%d is neither an armstrong or a magical number.\n", input);

 }

}

}

Explanation:

Here is a starting point. What's the definition of a magical number?

You might be interested in
Order the following routine maintenance tasks from most to least important when securing a computer. a. Verify anti-malware sett
spin [16.1K]

Answer:

The following are the order of the routine maintenance tasks that is C, A, B, D

Explanation:

For securing the computer system the user has to follow some steps related to the routine maintenance tasks.

  • Firstly, the user has to validate the settings on the Windows Update.
  • Then, they have to validate the settings on the anti-malware software.
  • Then, the user has to validate the setting related to the file-sharing system.
  • Finally, they have to validate the frequent optimization of hard drives or hard disks.
7 0
3 years ago
The hardware and software that must be implemented to support the applications that the primary activities use are a part of the
Contact [7]
The answer is infrastructure
7 0
2 years ago
Who wont me???????????????
Svet_ta [14]

Answer:

whatatattatata

Explanation:

what are u talking about

8 0
3 years ago
Read 2 more answers
When operating your vessel with a vhf radio, what channel must you monitor?.
Vladimir [108]

Answer: <u>Channel 16</u>. If you hear a MAYDAY call, remain silent, listen, and write down information about the boat in distress.

Hope this helps!

4 0
2 years ago
The recommended flux for electrical soldering is A. antimony. B. sal ammoniac. C. rosin. D. muriatic acid.
expeople1 [14]
I pretty sure its D muriatic acid
3 0
3 years ago
Other questions:
  • Assume the existence of a class named window with functions named close and freeresources, both of which accept no parameters an
    13·1 answer
  • C programming question:
    12·1 answer
  • 9. What is the difference between a hand-drawn sketch, a working drawing, and a 3D model?
    14·1 answer
  • Which term refers to a type of an attack in which an attacker makes his data look like it is coming from a different source addr
    10·1 answer
  • To maintain her audience's confidence in her, what should kiara not do while delivering her presentation?
    10·1 answer
  • When you pass an argument to a method, the argument's data type must be ____________ with the receiving parameter's data type?
    11·1 answer
  • Since the rules cannot address all circumstances, the Code includes a conceptual framework approach for members to use to evalua
    8·1 answer
  • Write a recursive function is_pow2(n) that returns True if the positive integer n is an integer power of 2, and False otherwise.
    9·1 answer
  • Consider the following method, which is intended to count the number of times the letter "A" appears in the string str.
    13·1 answer
  • Write a Dice Game program that generates two random dice values between 1 and 6 for you, and 2 for the computer. You get to roll
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!