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
Consider the recursive method myprint in this code snippet: public void myprint(int n) { if (n &lt; 10) { system.out.print(n); }
valkas [14]
What the method does, is it takes the rightmost decade and prints it, then divides by 10 and repeats. Effectively this means the number is printed backwards, so the output is 128.
7 0
3 years ago
What is the impedance mismatch problem? Which of the three programming
kykrilka [37]

Answer:

The problem that created due to the difference in the model of programming language and the database model.

Explanation:

The practical relational model has three components which are as follows

1. Attributes

2. Datatypes

3. Tuples

To minimize this problem  

1. We switch low pass L-Network to high pass L-network

2. We switch high pass L-Network to low pass L-network

3. We use the impedence matching transformer

3 0
3 years ago
Identify a major drawback of browsing web pages on mobile devices.
Pavlova-9 [17]
It was way too much of a drawback
5 0
3 years ago
Which of the following correctly identifies a voltage source and its method of developing electric potential?
Semenov [28]
Dry cell- Chemical action
8 0
2 years ago
Read 2 more answers
How do you design and create video games for what console game That you want To have it in
Yakvenalex [24]

Answer

Making a video game is much less daunting than it might seem. While you likely aren’t going to go from having no experience to making the next Grand Theft Auto, it has actually never been easier to get started making games. Game development tools and resources have become increasingly accessible to the average person, even if they have no programming experience. Often these tools are also available for free.

To try to make things easier for those looking to get started making games, we’ve put together a list of 11 game engines / editors. Some are designed for a specific genre of game or to be incredibly easy for newcomers. Others are professional development tools for AAA games, but are effectively free to use for hobbyists and still offer a lot of learning tools to help those with limited programming experience get started.

There are, of course, a lot of things that go into game development — music, animation, sound, writing, texturing, modeling, etc. — however, the game engine / editor you choose is going to have the biggest effect on what kind of game you can make. If you have suggestions for other engines, software, or learning tools for the other aspects of development, post it in the comments.

7 0
2 years ago
Other questions:
  • Write a function called calculate() that accepts three integer Numbers as arguments, compute these values : Sum and Product and
    7·1 answer
  • A statement describing both the requirements that must be met by a product or process amd the ways in which satisfaction of the
    8·2 answers
  • You view a portion of a document on the screen through a ____.
    6·1 answer
  • Convert the following pseudi code to C++ code. BE sure to define the apprpriat evariables.
    9·1 answer
  • What X coordinate does the center of a game begin at?
    9·1 answer
  • Which statement describes Augmented Reality (AR) technology?
    12·1 answer
  • 5. Compare the telephone network and the internet. What are the similarities? What are the differences?
    12·1 answer
  • Generalized goals are more likely to be achieved than specific goals. True or False
    7·1 answer
  • ________ is the art of manipulating people into breaking normal security procedures or divulging confidential information.
    12·1 answer
  • (Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!