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
riadik2000 [5.3K]
1 year ago
11

write a program that computes an integer's checksum. to compute the checksum, break the integer into its constituent

Computers and Technology
1 answer:
Serggg [28]1 year ago
8 0

Using the knowledge in computational language in python it is possible to write a code that computes an integer's checksum.

<h3>Writting the code:</h3>

<em>def checkSum(n):                    # Function definition</em>

<em>    total = 0                       # total variable which returns sum</em>

<em>    c = 0                           # counter variable which count the even position</em>

<em>    while(n!=0):                    # running a loop while n != 0</em>

<em>        r = int(n%10)               #breaking the number into digits</em>

<em>        c=c+1                       # increase counter</em>

<em>        if c%2==0:                  # if counter is even position then double the number </em>

<em>            r = r*2</em>

<em>            while(r!=0):                            # do the process</em>

<em>                total = total + int(r%10)</em>

<em>                r = int(r/10)</em>

<em>            n=int(n/10)    </em>

<em>        else:                       # if counter is odd position then simple add the digit </em>

<em>            total = total + r       # into total</em>

<em>            n=int(n/10)</em>

<em>    return total                    # in the last return the sum of digits</em>

<em># Driver code</em>

<em>n = int(input("Enter Number:"))         # asking user to enter the number </em>

<em>print(checkSum(n))                      # calling the function</em>

See more about python at brainly.com/question/18502436

#SPJ1

You might be interested in
You can use a(n) to call a function in response to an event?
uranmaximum [27]

Answer:

Simply put: A callback is a function that is to be executed after another function has finished executing — hence the name 'call back'. ... Functions that do this are called higher-order functions. Any function that is passed as an argument is called a callback function.

Explanation:

6 0
2 years ago
You are trying to troubleshoot a desktop power supply issue using a voltmeter. Which of the following options are the MOST commo
vredina [299]

Answer:

The correct answers are: (A) +/- 5V and (B) +/- 12V

Explanation:

First at all, the purpose of the power supply is transforming from AC (Alternating Current) to DC (Direct Current) for use this energy in chips and electronics devices that consume this type of power. Usually the most common DC voltage for electronics is 5V but in your CPU you also have other devices that might going to need more voltage like fan or hard drives thats ´s why 12V is an also an option. Now some other devices are going to need negative sources such -5V or -12V as well.

7 0
2 years ago
Which line of code will only allow a symbol to be stored in a variable?
nataly862011 [7]
<h2>Answer:</h2><h2></h2><h2>phone = int(input("What is your phone number?"))</h2><h2></h2><h2>Hope this helps, have a great day, stay safe, and positive!!</h2>

8 0
2 years ago
Read 2 more answers
How do I find a space in my String and replace it? JAVA
Fantom [35]

Answer:

This article shows how to use regex to remove spaces in between a String.

A string with spaces in between.

String text = "Hello World Java.";

We want to remove the spaces and display it as below:

Hello World Java.

1. Java regex remove spaces

In Java, we can use regex \\s+ to match whitespace characters, and replaceAll("\\s+", " ") to replace them with a single space.

Regex explanation.

`\\s` # Matches whitespace characters.

+ # One or more

StringRemoveSpaces.java

package com.mkyong.regex.string;

public class StringRemoveSpaces {

public static void main(String[] args) {

String text = "Hello World Java.";

String result = text.replaceAll("\\s+", " ");

System.out.println(result);

}

}

Output

Terminal

Hello World Java.

8 0
3 years ago
We are continuously sending and receiving messages that may change midstream. This illustrates that____________.
8_murik_8 [283]

Answer:

Communication is a constant process and it can also be corrupted.

Explanation:

Communication is the ability to send and receive messages that can be understood. We constantly communicate with our environment verbally and or orally, using signs and language to express ourselves.

Messages sent can and should be decoded for communication to be complete. It can be corrupted on its path to the decoder, this hinders understanding.

6 0
3 years ago
Other questions:
  • In Microsoft Windows, which of the following typically happens by default when a file is "double-clicked"
    10·2 answers
  • Whenever I go onto Google Chrome, the words are in Spanish! How can I make the words be back in English again? Please let me kno
    7·1 answer
  • The ____ allows a core to communicate with other cpu components, such as the memory controller and other cores
    14·1 answer
  • How do Web browsers interact with URL/URIs to navigate the internet
    14·1 answer
  • Outlines are effective because
    13·2 answers
  • ____________ are collected from several entities at the same point in time.
    13·1 answer
  • Which property of a text element controls how the browser handles text that does not fit within the element box?
    13·1 answer
  • I need a good science fair name I’m doing a homemade water filter and I have no idea what the title should be plz help
    14·1 answer
  • What is the ethical danger of using agents in negotiation?
    15·1 answer
  • Write a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program shou
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!