c programming question


Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. The input will be a non-negative integer.

Answers

Answer 1

Answer:

int digitSum(int n) {

int sum = 0;

while (n) {

 sum += n % 10;

 n /= 10;

}  

return sum < 10 ? sum : digitSum(sum);

}

int main()

{

int n = 12345;

printf("Digit sum of %d is %d\n", n, digitSum(n));

}

Explanation:

The recursion takes care of the repeated summing in case the sum has more than 1 digit.


Related Questions

You are concerned that if a private key is lost, all documents encrypted using your private key will be inaccessible. Which service should you use to solve this problem

Answers

Answer:

Key escrow.

Explanation:

Cyber security can be defined as preventive practice of protecting computers, software programs, electronic devices, networks, servers and data from potential theft, attack, damage, or unauthorized access by using a body of technology, frameworks, processes and network engineers.

In Cyber security, encryption is a form of cryptography and typically involves the process of converting or encoding informations in plaintext into a code, known as a ciphertext.

Typically, an information or data that has been encrypted can only be accessed and deciphered by an authorized user.

Hence, if a private key is lost, all documents encrypted using that private key will be inaccessible to the users. Thus, the service that can be used to solve this problem is a key escrow because the cryptographic (private) keys kept in an escrow system are protected and would not be released to anyone other than the original user (owner).

A key escrow can be defined as a data security method of storing very essential cryptographic keys.

Simply stated, key escrow involves a user entrusting his or her cryptographic key to a third party for storage.

As a standard, each cryptographic key stored or kept in an escrow system are directly linked to the respective users and are encrypted in order to prevent breach, theft or unauthorized access.

Write either True or False. a) Software is touchable part of computer system. b) System software provides easy interaction between user and computer c) Every computer needs to have own operating system. d) A computer can only understand the program written in assembly language. SANJIWANI Computer Book 7​

Answers

Answer:

A: False B: False C: True D: False

Explanation:

Which SCSI standard allows for the technique known as “hot swapping”? Ultra SCSI Original SCSI Serial SCSI Fast-Wide SCSI

Answers

Answer:

Serial SCSI

Explanation:

Hot swapping can be defined as a process which typically involves fitting or replacing CD-ROM drive, hard-disk drive, power supply or other peripheral devices while a computer system is powered on. Thus, it allows for the installation or removal of a peripheral device from a computer while power is still being supplied to the computer i.e without having to shutdown the computer.

Serial SCSI is a SCSI standard which allows for the technique known as “hot swapping” because it's a point to point connection that is designed to move data to and from computer storage serially.

What is the role of a design tWhat is the role of a design tool in a Robotic Process Automation (RPA) solution?

Answers

Answer and Explanation:

Robotic Process Automation(RPA) are software tools that apply artificial intelligence(AI) technology to automate digital routine tasks for business executives. It mimics everyday tasks and automatically executes them for the user.

Design tools in RPA play the role of infusing the best design into RPA software, it works with the popular phrase "design thinking". Robotic process automation software are now in tune with the popular buzz of a user centered approach to design of RPA tools. This ideology focuses on deploying RPA software that appeals to users and are therefore market friendly.

write any four characteristics of desktop computer​

Answers

The characteristics of computers that have made them so powerful and universally useful are speed, accuracy, diligence, versatility and storage capacity. Let us discuss them briefly. Computers work at an incredible speed. A powerful computer is capable of performing about 3-4 million simple instructions per second

You make a purchase at a local hardware store, but what you've bought is too big to take home in your car. For a small fee, you arrange to have the hardware store deliver your purchase for you. You pay for your purchase, plus the sales taxes, plus the fee. The taxes are 7.5% and the fee is $20. (i) Write a function t(x) for the total, after taxes, on the purchase amount x. Write another function f(x) for the total, including the delivery fee, on the purchase amount x. (ii) Calculate and interpret (f o t)(x) and (t o f )(x). Which results in a lower cost to you

Answers

Answer:

[tex]f(x) = 1.075x[/tex]

[tex]t(x) = x + 20[/tex]

[tex](f\ o\ t)(x) = 1.075x + 21.5[/tex]

[tex](t\ o\ f)(x) = 1.075x + 20[/tex]

Explanation:

Given

[tex]Tax = 7.5\%[/tex]

[tex]Fee = \$20[/tex] -- delivery

Solving (a): The function for total cost, after tax.

This is calculated as:

[tex]f(x) = Tax *(1 + x)[/tex]

Where:

[tex]x \to[/tex] total purchase

So, we have:

[tex]f(x) = x * (1 + 7.5\%)[/tex]

[tex]f(x) = x * (1 + 0.075)[/tex]

[tex]f(x) = x * 1.075[/tex]

[tex]f(x) = 1.075x[/tex]

Solving (b): Include the delivery fee

[tex]t(x) = x + Fee[/tex]

[tex]t(x) = x + 20[/tex]

Solving (c): (f o t)(x) and (t o f)(x)

[tex](f\ o\ t)(x) = f(t(x))[/tex]

We have:

[tex]f(x) = 1.075x[/tex]

So:

[tex]f(t(x)) = 1.075t(x)[/tex]

This gives:

[tex]f(t(x)) = 1.075*(x + 20)[/tex]

Expand

[tex]f(t(x)) = 1.075x + 21.5[/tex]

So:

[tex](f\ o\ t)(x) = 1.075x + 21.5[/tex]

[tex](t\ o\ f)(x) = t(f(x))[/tex]

We have:

[tex]t(x) = x + 20[/tex]

So:

[tex]t(f(x)) = f(x) + 20[/tex]

This gives:

[tex]t(f(x)) = 1.075x + 20[/tex]

We have:

[tex](f\ o\ t)(x) = 1.075x + 21.5[/tex] ---- This represents the function to pay tax on the item and on the delivery

[tex](t\ o\ f)(x) = 1.075x + 20[/tex] --- This represents the function to pay tax on the item only

The x coefficients in both equations are equal.

So, we compare the constants

[tex]20 < 21.5[/tex] means that (t o f)(x) has a lower cost

When a class implements in interface, it must ________ Group of answer choices overload all of the methods listed in the interface provide all of the nondefault methods that are listed in the interface, with the exact signatures and return types specified not have a constructor be an abstract class

Answers

Answer:

provide all of the nondefault methods that are listed in the interface, with the exact signatures and return types specified

Explanation:

I am assuming the programming language is Java. Actually, none of the answers are 100% correct, but this one is the only one that is partially correct. The reason is the class implementing an interface can be abstract, and in this case it may not provide ALL nondefault methods.

What is the output?
>>> password = "sdf345"
>>> password isalpha()
>>>

Answers

Explanation:

the output password is isalpha()

When a statement within a try block causes an exception, the remaining statements in the try block Select one: a. are executed after the statements in the catch block b. are executed before the statements in the catch block c. aren't executed

Answers

In C++, 'Try block' comprises of a group of statements in which there is a probability of an exception to take place.

C). The statements that would be left in the try block in case a particular statement leads to an exception 'can't be executed.'

In case an exception takes place, the left statements in the try block fail to function. This is the primary reason for which a catch block immediately succeeds a try block in order to deal with the exception and help close that code to allow the statements to work. Thus, option C is the correct answer.

Learn more about 'Try block' here:

brainly.com/question/14186450

Type the correct answer in each box. Spell all words correctly.

Digital artist Frank is discussing how to enhance scanned or photographed images. Complete the following sentences while keeping in mind the topic of discussion.

You can rework or enhance scanned or photographed images using photo editing and illustration software or by using a digital____.

The device has a_____surface on which you can draw images, graphics, and animations.

Answers

Answer:

1. Tablet

2. Flat

Explanation:

What is malware? a type of virus that spreads through a network connection a type of virus that targets programs and files any program designed to do harm a type of software designed to track activity online

Answers

a malware is any program designed to do harm

Explanation:

a malware (malicious software) is any software intentionally designed to cause damage to a computer,server, client or computer network.

what do you mean by automation and diligence with respect to a computer??​

Answers

Answer:

Delegince computer without any motion resists

What is a single physical processor? plz help​

Answers

Answer:

A physical processor which is also referred to as a CPU, is a chip that is visible on a computer's circuit board.

Explanation:

write any five main features of fourth generation of computer?​

Answers

1) The fourth generation computers have microprocessor-based systems. It uses VLSI (Very Large Scale Integrated) circuits.
2) They are the cheapest among all the computer generation.
3) The speed, accuracy and reliability of the computers were improved in fourth generation computers.
i hope this helps you

What impact, if any, have advances in technology had on people’s ability to communicate through media? Advances in technology have had no measurable impact on people’s ability to communicate through media. Advances in technology have made it more difficult for people to communicate through media. Advances in technology have made it easier for people to communicate through media. Advances in technology have had made it both easier and more difficult to communicate through media.

Answers

Answer:

What impact, if any, have advances in technology had on people's ability to communicate through media? Advances in technology have made it easier for people to communicate through media.

Answer:

advances in technology made it easier for ppl to communicate through media

Explanation:

because i got it right

Bruce frequently works with a large number of files. He is noticing that the larger the files get, the longer it takes to access them. He suspects that the problem is related to the files being spread over the disk. What utility can be used to store the files contiguously on the disk

Answers

The utility that could be stored for the files is disk defragmenter.

The following information related to the disk defragmenter is:

In the case when the program saved the file on the disk so here the file should be put onto the empty space. It considered all the parts & pieces on each and every file and the same should be stored in one place.Also, the programs should be kept in one place, and the space that is not used should be on the hard disk.

Therefore we can conclude that The utility that could be stored for the files is disk defragmenter.

Learn more about the disk here: brainly.com/question/12656426

What is a monitor?
i can ask everyone ​

Answers

Answer:

a screen which displays an image generated by a computer.

Explanation:

A monitor is a piece of computer hardware that displays the video and graphics information generated by a connected computer through the computer's video card. Monitors are similar to TVs but usually display information at a much higher resolution. Also unlike televisions, monitors typically sit atop a desk rather than being mounted on a wall.

please help me with this this is Computer chapter Advanced HTML of class 8th​

Answers

Answer:

ok let me try

It stands for

Hypertext Markup Language

Image result for html stands for

HTML (the Hypertext Markup Language) and CSS (Cascading Style Sheets) are two of the core technologies for building Web pages. HTML provides the structure of the page, CSS the (visual and aural) layout, for a variety of devices.

Which of these would you use to connect a mouse to a computer?
O RAM
O ROM
O USB
O TOT

Answers

USB is the answer because that is the adapter to plug it in

4) Programming a) WAp to find the greatest number among any three numbers.​

Answers

def comp_num (num1, num2, num3):

try:

if num1 > num2 and num1 > num3:

print ( "{0} is the biggest".format(num1) )

elif num2 > num1 and num2 > num3:

print ( "{0} is the biggest".format(num2))

elif num3 > num2 and num3 > num1:

print ( "{0} is the biggest".format(num3))

except ValueError:

return "Invalid input"

num_1 = int (input (" Please enter a number: "))

num_2 = int (input (" Please enter a second number: "))

num_3 = int (input (" Please enter a third number: "))

print (comp_num (num_1, num_2, num_3))

Answer:

this is in qbasic programming

It is used to select specific menu options, drag and drop options and to draw something on screen.

Answers

Answer:

A mouse.

Explanation:

An input device can be defined as any device that is typically used for sending data to a computer system.

Generally, all of the output and input device of a computer are known as peripheral (external) devices and they provide data (informations) to the end users in various formats such as video, audio, texts, images etc.

Since input devices are peripheral (external) devices, they can be connected to the computer system wirelessly or through a wired-connection (cable).

Some examples of peripheral (external) devices are monitor, speakers, keyboard, printer, scanner, projector, mouse, etc.

A mouse is an input device that is designed and used to select specific menu options, drag and drop options and to draw something on screen.

You are the security analyst for your organization. Clients are complaining about being unable to connect to the wireless network. After looking into the issue, you have noticed short bursts of high-intensity RF signals are interfering with your wireless network's signal. Which type of attack are you most likely experiencing

Answers

Explanation:

denial of service attacks (dos)

Based on the above, the kind of attack the person is most likely experiencing is known as jamming.

What is Electronic jamming?

This is known to be a kind of  electronic warfare that is the use of jammers that shows interfering signals toward an enemy's system and thus it often blocks the receiver.

Therefore, Based on the above, the kind of attack the person is most likely experiencing is known as jamming.

Learn more about jamming from

https://brainly.com/question/17488276

#SPJ9

Your help desk has informed you that they received an urgent call from the vice president last night requesting his logon ID and password. You discussed about the call with the VP today and you got to know he never made that call. What type of attack is demonstrated in the given scenario

Answers

Answer:

Social Engineering Attack

Explanation:

The exploitation of individuals in order to gain confedential information is a Social Engineering Attack. These attacks typically take advanage of one's emotions or they use inpersonaltion to steal data.

read more here: https://www.webroot.com/us/en/resources/tips-articles/what-is-social-engineering

Lmk if this helps! :)

c) Explain GIGO briefly.​

Answers

Answer:

Is is also a computer science acronym that implies bad input will result in bad output. Requiring valid input also helps programs avoid errors that can cause crashes and other erratic behavior.

IT'S FORMULA IS GIGO: GARBAGE IN GARBAGE OUT...

HOPE IT'S HELPFUL FOR U!!

AND PLZ MARK ME AS BRAINLIEST IF U LIKE THIS ANSWER!!!!

If an angry person called and demanded to speak with the executive you support, who is currently unavailable, how would you handle it?

Answers

Answer: be nice no matter how mean or rude the person is.

Explanation: because if you’re not you can get in big trouble or fired.

Answer:

remain  calm during the conversation

The information included in a résumé should always relate to the job objective; if it isn’t related, it shouldn’t be included.

Answers

Answer:

True.

Explanation:

A resume (curriculum vitae) can be defined as a short text-based document that a job applicant use to briefly outline his or her qualifications, abillities and accomplishments, haven completed and obtained an academic certificate. Thus, it is used to briefly outline a person's qualifications, abillities, skills set, and accomplishments, after completing and obtaining an academic certificate such as a bachelor's degree, master's degree, etc.

Generally, all job applicants are required to have a resume (curriculum vitae). This brief and concise document is always requested by human resource managers during the job application process.

Furthermore, the primary way to make a resume persuasive (to convince or inform an action in the minds of the readers - potential employers) is by customizing it to fit each company and position.

Hence, the information included in a résumé should always relate to the job objective; if it isn’t related, it shouldn’t be included.

This ultimately implies that, job applicants are expected to tailor their resume to fit or match the position that is advertised by a company's human resources department.

How to execute python code in command prompt *window*?

Iam using sublime text 3 and want to execute my python code in command prompt.
This is my current build system:

{
"cmd": ["python", "$file"],
"selector": "source.python",
"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}

But I want my program to open in command prompt window and show the result there. I dont want to see the result in sublime text. Please help.

Answers

Answer:

Open Command Prompt and type “python” and hit enter. You will see a python version and now you can run your program there

A transition is ________.

Answers

Answer:

the process or a period of changing from one state or condition to another.

Explanation:

"students in transition from one programme to another"

¿Cuál es la ventaja principal de una tabla dinámica?

Answers

Explanation:

Ventajas de las tablas dinámicas de Excel:

Hacen que los informes sean flexibles y se adaptan a tus necesidades. Son una forma interactiva de resumir rápidamente grandes volúmenes de datos, haciendo mucho más fácil el proceso de análisis y permitiendo encontrar patrones o tendencias.

How is IT used in entertainment to make cartoon movies

Answers

Answer:

Forensic animation is a branch of forensics in which animated recreation of incidents are created to aid investigators & help solve cases. Examples include the use of computer animation, stills, and other audio visual aids.

hope you will get this answer correct

Other Questions
Can somebody help me what must be added to x3-3x2-12x+19 so that the result is exactly divisible by x2+x-6? Disability rights organizations backed laws requiring . A. public places to provide access for people with disabilities B.free education for all children C.programs such as Medicare D.private homes to provide access for people with disabilities find the square root of the following number 8136.04 PLEASE HELP ASAPBelinda is thinking about buying a house for $179,000. The table below shows the projected value of two different houses for three years:Number of years 1 2 3House 1 (value in dollars) 186,160 193,606.40 201,350.66House 2 (value in dollars) 190,000 201,000 212,000Part A: What type of function, linear or exponential, can be used to describe the value of each of the houses after a fixed number of years? Explain your answer. (2 points)Part B: Write one function for each house to describe the value of the house f(x), in dollars, after x years. (4 points)Part C: Belinda wants to purchase a house that would have the greatest value in 30 years. Will there be any significant difference in the value of either house after 30 years? Explain your answer, and show the value of each house after 30 years. (4 points) 1. A turtle and a rabbit are to have a race. The turtles average speed is 0.9 m/s. The rabbits average speed is 9 m/s. The distance from the starting line to the finish line is 1500 m. The rabbit decides to let the turtle run before he starts running to give the turtle a head start. If the rabbit started to run 30 minutes after the turtle started, can he win the race? Explain. !!!!Please Answer Please!!!!ASAP!!!!!!!!!!!!!!!!!!! What is the answer to this ? No one saw me change into passive voice NEED THIS ASAPAs Clover looked down the hillside her eyes filled with tears. If she could have spoken her thoughts, it would have been to say that this was not what they had aimed at when they had set themselves years ago to work for the overthrow of the human race. These scenes of terror and slaughter were not what they had looked forward to on that night when old Major first stirred them to rebellion. If she herself had had any picture of the future, it had been of a society of animals set free from hunger and the whip, all equal, each working according to his capacity, the strong protecting the weak, as she had protected the lost brood of ducklings with her foreleg on the night of Majors speech.Animal Farm,George OrwellHow does Clovers response support the authors purpose? Check all that apply.She feels great despair, like many people in the Soviet Union.She was wrong to think that the strong would protect the weak.She is pleased with the changes on the farm, although life is not perfect.She is correct in thinking that taking over the farm has solved all their problems.She is similar to peasants who thought that the rebellion would create a better world. Using the following accounts and an overhead rate of 70% of direct labor cost, determine the amount of applied overhead. Work in Process Inventory Beginning WIP 23,900 Direct Materials 71,700 Direct Labor ?Applied Overhead ?To Finished Goods Ending WIP 39,190 Finished Goods Inventory Beginning FG 5500 150610 Ending FG The Supreme Courts ruling in the civil rights cases of 1883 led to Part A: which statement best expresses a theme of the short story A its better to downplay your own intelligence.B the government has been known to violate peoples rights .C high intelligence can be viewed as a dangerous thing.Sprocket have higher expectations for children as they grow up Plsss help... question from gradients. Will give brainliest Read this excerpt from "Edward Jenner and the History of Smallpox and Vaccination.In 1757, an 8-year-old boy was inoculated with smallpox in Gloucester; he was one of thousands of children inoculated that year in England. The procedure was effective, as the boy developed a mild case of smallpox and was subsequently immune to the disease. His name was Edward Jenner.How does this excerpt help support the main claim of the passage that Jenner helped spread the practice of immunization? It includes evidence that inoculation was used in Gloucester.It points out that Jenner was one of thousands of children in England.It provides information about Jenners early experiences with smallpox.It indicates that smallpox spread throughout England in the eighteenth century. Black people were not significantly impact by the 2008 mortgage crisis. What the correct answer to the question true or false Six women push grocery carts up a ramp as shown.2 carts weigh 50 lbs. each.4 carts weigh 20 lbs. each.How much work was done?_____________ ft.-lbs. (total work) Which branch of government creates most government agencies?A.) the legislative branchB.) the executive branch C.) other agencies D.) the judicial branch What are the solutions of x2+ 6x-6= 10?X=-11 or X= 1X=-11 or X=-1X=-8 or X=-2X=-8 or X= 2 Diego's family truck holds 21 gallons of fuel. Each day the car uses 1.5 gallons of fuel. A warning light comes on when the remaining fuel is 2.5 gallons or less. Starting from a full tank, can Diego's family drive the car for 10 days without the warning light coming on? Explain or show your reasoning. Starting from a full tank, can Diego's family drive the car for 15 days without the warning light coming on? Explain or show your reasoning. Diego says the expression 21 - 1.5t helps him understand this situation. In this situation, what does this expression represent, and what does the variable t stand for? Write and solve an equation to determine the number of days Diego's father can drive the car without the warning light coming on. Write and solve an inequality that represents the number of days driven without the warning light coming on. Explain clearly what the solution to the inequality means in the context of this situation