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
madam [21]
3 years ago
11

Write a program that reads an integer between o and 1000 and adds all the digits in the integer. For example, if an integer is 9

32, the sum of all the digits is 14. Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit. For instance, 932 % 10=2 and 932/10 =93. Here is a sample run:
Enter a number between 0 and 1000 : 999
The sum of digits is 27.
Computers and Technology
1 answer:
ale4655 [162]3 years ago
6 0

Answer:

Answered below

Explanation:

#Program is written in Python programming language

digit = 0

sum = 0

num = int(input("Enter a number between 0 and 1000: ")

#Check that number is within the valid range

if num > 0 and num <= 1000:

while num != 0:

#Isolate each digit

digit = num % 10

sum = sum + digit

#Remove isolated digit from number

num = num/10

else:

print("Number is not within valid range")

#print total sum of digits

print(sum)

You might be interested in
The main reason for using a comment in your HTML code is to
zvonat [6]

Answer:

D, document and explain parts of code

Explanation:

Mark me brainliest :)

8 0
2 years ago
Which feature of a typical professional networking site helps users add professional details to their profile ?
ludmilkaskok [199]
All I  could find are networking cites allow people to take pics of themselves for a personal effect! hope this is what your looking for.
7 0
3 years ago
Read 2 more answers
List four types of ic packages​
Pani-rosa [81]

Answer:

C-DIP: Ceramic Dual In-line Package.

CERDIP: Ceramic DIP, which is the same as C-DIP.

CPGA: Ceramic Pin Grid Array.

DIL: Dual In-Line; see note below.

DIP: Dual In-line Package; DIP Socket Styles.

TBD: Dual In-line Zig-Zag Package; Zig-Zag Package.

HDIP: Hermetic DIP.

PDIP: Plastic DIP [P-DIP]

Explanation:

6 0
3 years ago
In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, c
Anton [14]

Answer:

The correct answer for the given question is "2"

Explanation:

Here the statement is  cookies = number % children; where  number and children are the integer type variable which has been initialized by 38 and 4  respectively as given in the question.  

It will give value of cookies=2 because the % operator gives reminder so 38%4 gives reminder 2 .  

Therefore the value of cookies=2;

8 0
3 years ago
The __________ algorithm takes the ciphertext and the secret key and produces the original plaintext
Bad White [126]
The answer is decryption
8 0
3 years ago
Other questions:
  • Write two versions of a program that reads a sequence of positive integers from the user, calculates their geometric mean, and p
    13·1 answer
  • What is the first step to creating a PivotTable?
    9·2 answers
  • What kind of voltage do solar cells generate? Solar cells produce ______ voltage which is not usable by most household appliance
    15·1 answer
  • What is a sending device? a device on which data, instructions, and information travel a device that accepts the transmission of
    5·1 answer
  • What would happen if the bitmap or free list containing the information about free disk blocks was completely lost due to a cras
    9·1 answer
  • Random letter of the alphabet for Python coding
    11·2 answers
  • PLEASE HELP! I'm offering brainliest!
    6·1 answer
  • What were thomas edison's contributions to advances in technology?
    9·1 answer
  • Select the correct answer from each drop-down menu.
    8·1 answer
  • What are the importance of rules in the computer lab ?​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!