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
Each year, Doritos sponsors a Crash the Super Bowl contest, encouraging individuals to submit ads for Doritos to the contest. Th
monitta

Answer:

The answer is creators.

Explanation:

<em>Creators are contributors capable to inovate and share creative ideas. They are not necessarily advertising  and marketing professionals. They can have art, design, music,  and other backgrounds, but the most relevant characteristic of this group of people is their creativity.</em>

<em>They are behind all the great ideas we see at the most relevant social medias nowadays.</em>

7 0
3 years ago
A method countDigits(int num) of class Digits returns the remainder when the input argument num(num &gt; 0) is divided by the nu
sertanlavr [38]

Answer:

#include <iostream>

using namespace std;

class Digits

{

   public:

   int num;

   int read()       //method to read num from user

   {

       cout<<"Enter number(>0)\n";

       cin>>num;

       return num;

   }

   int digit_count(int num)  //method to count number of digits of num

   {

       int count=0;

       while(num>0)    //loop till num>0

       {

           num/=10;

           count++;   //counter which counts number of digits

       }

       return count;

   }

   int countDigits(int num)   //method to return remainder

   {

       int c=digit_count(num); //calls method inside method

       return num%c;  

   }

};

int main()

{

   Digits d;    //object of class Digits is created

   int number=d.read();   //num is read from user

   cout<<"\nRemainder is : "<<d.countDigits(number);  //used to find remainder

   return 0;

}

Output :

Enter number(>0)

343

Remainder is : 1

Explanation:

As program is missing to find errors , a logically write program is written to find the remainder when a number is divided by its number of digits. A class  Digits is constructed which has public variable num and methods read(), digit_count(), countDigits().

  • read() - This method reads value of num from the user and return num.
  • digit_count() - This method takes a integer as parameter and counts the number of digits of a number passed as argument. while loop is used to increement the counter until num<0. This returns the value of count.
  • countDigits() - This method takes a integer as a parameter and returns remainder when the argument is divided by number of  digits of argument. Number of digits is calculated by using method digit_count().

At last in main method , object of Digits class is created and its methods are used to find the output.

7 0
3 years ago
• Write a program that asks the user to enter a number of seconds. • If there are less than 60 seconds input, then the program s
serious [3.7K]

Answer:

The solution code is written in Python:

  1. sec = int(input("Enter number of seconds: "))
  2. if(sec >=60):
  3.    min = sec // 60
  4.    sec = sec % 60
  5. else:
  6.    min = 0
  7. print(str(min) + " minutes " + str(sec) + " seconds")

Explanation:

Firstly, use input function to prompt user to enter number of seconds and assign the input value to variable sec (Line 1).

Next, create an if statement to check if the sec is bigger or equal to 60 (Line 3). If so, we user // operator to get minutes and use % operator to get the seconds (Line 4 - 5).

Then we use print function to print the minutes and seconds (Line 9).

6 0
3 years ago
Read 2 more answers
Why is monitoring email, voice mail, and computer files considered legal?
Sati [7]

Explanation:

Monitoring someone's emails,voice mails and computer files is considered is illegal because you are accessing someone's personal information which is not regarded as  ethical .

There are certain reasons where one's email,voice mails and computer files can be monitored are as following:

  1. Protect the security information and security.
  2. Investigation of complaints of harassment.
  3. Preventing personal use of employer's facilities.
6 0
3 years ago
Which hardware device is it most important to an experienced computer professional to install
kherson [118]

Answer:

RAM

Explanation:

In the test

3 0
3 years ago
Other questions:
  • In order to look up ipv4 and ipv6 dhcp leases, what two files should be viewed?​
    10·1 answer
  • When enter a function or formula in a cell, which is the character you must type?
    14·1 answer
  • An email can lead to miscommunication because:
    6·2 answers
  • Nvm, Its B.
    10·1 answer
  • 2. Suppose you want to write a method that prints a heading on a new output page, along with a page number that is 1 in the firs
    15·1 answer
  • Whitch action should a user take to ensure that formatting is applied to a row? A. use the ctrl+a keys. B. highlight the whole t
    11·1 answer
  • Which of the following is NOT areserved word in Java?intpublicstaticnum
    9·1 answer
  • Consider two vectors that are NOT sorted, each containing n comparable items. How long would it take to display all items (in an
    8·1 answer
  • Write a for loop that uses the loop control variable to take on the values 0 through 10.
    10·1 answer
  • Mention and explain various alignment options​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!