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
Art [367]
4 years ago
15

unsigned int SumOfDigits(unsigned int n)Description: Develop a function that takes a non-negative integer n as a parameter and r

eturns a non-negative integer containing the sum of n’s digits. For example, if the input parameter n was 17239 then the output of this function should be 1 + 7 + 2 + 3 + 9 = 22
Engineering
1 answer:
Verdich [7]4 years ago
7 0

Answer:

The solution code is written in C++.

  1. unsigned int SumOfDigits(int n){
  2.    int sum = 0;
  3.    sum += n % 10;
  4.    n = n / 10;
  5.    
  6.    while(n != 0){
  7.        sum += n % 10;
  8.        n = n / 10;
  9.    }
  10.    
  11.    return sum;
  12. }

Explanation:

Firstly, define a function with name <em>SumOfDigits()</em> that take one input integer, <em>n</em> and return an unsigned summation integer (Line 1). Next, we declare a variable sum to hold the value of summation of all the integer digits. Let's initialize it with zero (Line 2).

We can get the first digit from the integer by calculating the remainder of n after dividing it by 10 using modulus operator (%) and the remainder obtained is added to the sum variable (Line 3). Next, we divide the integer n by 10 (Line 4). This will discard the last digit of integer n (from the right).

We just need to repeat the process from Line 3-4 using a while loop so long as the current integer n is not zero (Line 6-8). We shall be able to take out the individual digit and add it to variable<em> sum</em>.  

At the end, return the <em>sum</em> as output (Line 11).

You might be interested in
Many farms and ranches use electric fences to keep animals from getting into or out of specific pastures. When switched on, an e
Nikolay [14]

Answer:

Aluminum

Explanation:

The best material to use when creating an electric fence would be Aluminum. Aluminum wiring is incredibly durable and can be easily obtained. Since aluminum is a non-magnetic metal its conducting capabilities far exceed other metallic options in the market and is also why companies choose aluminum for their high tension cable wiring. Aside from being more expensive than other feasible options its durability and conducting capabilities make it easily the best option.

7 0
3 years ago
Read 2 more answers
How do you make a robotic dog
fredd [130]
In order to create a robotic dog, you are needing the necessary parts to create Goddard from Jimmy nutreon boy genius
7 0
4 years ago
Read 2 more answers
Which group might be classified as a gang?
Furkat [3]

Answer:

The following criteria are commonly used for classifying groups as gangs: The group has three or more members, generally aged 12–24. Members share an identity, typically linked to a name, and often other symbols. Members view themselves as a gang, and they are recognized by others as a gang.

Explanation:

8 0
3 years ago
Read 2 more answers
Air (cp = 1.005 kJ/kg·°C) is to be preheated by hot exhaust gases in a cross-flow heat exchanger before it enters the furnace. A
uysha [10]

Answer:

Q=67.95 W

T=119.83°C

Explanation:

Given that

For air

Cp = 1.005 kJ/kg·°C

T= 20°C

V=0.6 m³/s

P= 95 KPa

We know that for air

P V = m' R T

95 x 0.6 = m x 0.287 x 293

m=0.677 kg/s

For gas

Cp = 1.10 kJ/kg·°C

m'=0.95 kg/s

Ti=160°C   ,To= 95°C

Heat loose by gas = Heat gain by air

[m Cp ΔT] for air =[m Cp ΔT] for gas

by putting the values

0.677 x 1.005 ( T - 20)= 0.95 x 1.1 x ( 160 -95 )

T=119.83°C

T is the exit temperature of the air.

Heat transfer

Q=[m Cp ΔT] for gas

Q=0.95 x 1.1 x ( 160 -95 )

Q=67.95 W

7 0
3 years ago
Drag the tiles to the boxes to form correct pairs. Identify the designations of the three employees in an automobile company fro
aniked [119]

Answer:

is the fare of our responsibility towards

7 0
3 years ago
Other questions:
  • If the specific surface energy for aluminum oxide is 0.90 J/m2 and its modulus of elasticity is (393 GPa), compute the critical
    11·1 answer
  • Ayuda porfavor es para una tarea de mi capacitación de desarrollo microempresarial
    14·1 answer
  • If there are 16 signal combinations (states) and a baud rate (number of signals/second) of 8000/second, how many bps could I sen
    9·1 answer
  • An aluminium alloy bar of diameter 12.5 mm and length 27 m loaded in uniaxial tension to a force of 3 kN. Determine the length o
    15·1 answer
  • Water of dynamic viscosity 1.12E-3 N*s/m2 flows in a pipe of 30 mm diameter. Calculate the largest flowrate for which laminar fl
    13·1 answer
  • Fill in the blank to correctly complete the statement below.
    10·1 answer
  • Which system provides an easier way for people to communicate with a computer than a graphical user interface (GUI)?
    15·1 answer
  • PLEASE HELPPPPPPP!!!!,
    10·2 answers
  • What is the locating position of the land field?​
    8·2 answers
  • The percentage modulation of AM changes from 50% to 70%. Originally at 50% modulation, carrier power was 70 W. Now, determine th
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!