Computer Science, asked by varz3793, 1 year ago

Write an algorithm for sum of digits in a given number

Answers

Answered by dhanushkarkera2
5

Answer:

STEP 1 : START

STEP 2 : INPUT N

STEP 3 : CALCULATION

SUM=0

WHILE (N! =0)

REM=N%10 ;

SUM = SUM +REM;

N= N/10;

STEP 4 : OUTPUT

PRINT SUM

STEP 5 : STOP

Answered by syed2020ashaels
6

Answer:

There are many ways to write an algorithm. Some are very informal, some are quite formal and mathematical in nature, and some are quite graphic.

Explanation:

STEP 1 : START

STEP 2 : INPUT N

STEP 3 : CALCULATION

SUM=0

WHILE (N! =0)

REM=N%10 ;

SUM = SUM +REM;

N= N/10;

STEP 4 : OUTPUT

PRINT SUM

STEP 5 : STOP

There are many ways to write an algorithm. Some are very informal, some are quite formal and mathematical in nature, and some are quite graphic. The instructions for connecting a DVD player to a TV are algorithms. A mathematical formula like πR2 is a special case of an algorithm. The form is not particularly important as long as it provides a good way to describe and review the logic of the plan.

Developing an algorithm (plan) is a key step in solving a problem. Our algorithm development process consists of five main steps.

Step 1: Get a description of the problem.

This step is much more difficult than it seems. The developer must create an algorithm that solves the client's problem.

Step 2: Analyze the problem.

The purpose of this step is to determine the starting and ending points of the problem solution. This process is analogous to a mathematician determining what is given and what must be proved. A good description of the problem makes this step easier.

Step 3: Create a high-level algorithm.

An algorithm is a blueprint for solving a problem, but blueprints come in several levels of detail. It is usually better to start with a high-level algorithm that covers the main part of the solution but leaves the details for later. We can use an everyday example to demonstrate the algorithm at a high level.

A high-level algorithm shows the main steps to follow to solve a problem. Now we need to add details to these steps, but how much detail should we add?  We need to consider who (or what) will implement the algorithm and how much that person (or thing) already knows how to do. If someone is going to buy Mark's birthday card on my behalf, my instructions need to be tailored to whether or not that person knows the shops in the community and how well the buyer knows my brother's taste in greeting cards.

Step 5: Review the algorithm.

The last step is to check the algorithm. what are we looking for? First, we need to work through the algorithm step by step to see if it solves the original problem. Once we are convinced that an algorithm provides a solution to a problem, we start looking for other things. The following questions are typical of those we should ask ourselves whenever we review an algorithm. Asking these questions and finding the answers to them is a good way to develop skills that can be applied to the next problem.

brainly.in/question/31778565

#SPJ3

Similar questions