Click to like/follow us on:
Outline the algorithm that will request for an integer number n, and n different numbers Xi, afterwards it will calculate and display the summation (Total/sum) of all the Xi numbers? using the formula below;

Solution:
Major Steps
1. Request Data
2. Calculate sum
3. Display sum
Stepwise Refinement
1. Request Data
    1.1 Request n
2. Determine score
    2.1 sum = 0
    2.2 count = 1
    2.3 Request Xi
    2.4 sum = sum + Xi
    2.6 Repeat 2.3 and 2.4 until count <= n
3. Display sum
Explanation:
Why is the sum initialised to 0? Because 0 + any number (the first number of Xi) is that number and that is it. Just like in the product example, this is how the sum will be computed if the numbers Xi, supplied are:
2, 6, 3, 5, 4, 1.That is n = 6 then sum will be:
sum = 0 + 2,
sum = 2 + 6,
sum = 8 + 3,
sum = 11 + 5,
sum = 16 + 4,
sum = 20 + 1.
Then line 3 will display 21 as the summation of the numbers. When summing at each point the previous value of sum id erased and a new value assigned to it. For the first value sum = 0 + 2, here sum = 2. The previous value '0' has being erased and this process continues until the numbers xi, are exhausted.
You have to initialise count to be count = 1. The is from the equation given above. That count will start from ‘i’; where i start from 1 to n (i = 1, …, n).
The next example will teach you how to count from any integer number to any integer number.

SHARE THIS POST WITH YOUR FRIENDS...::

Related Posts:

  • Basic Computer OrganisationComputer organisation is a branch of computer design that deals with description of computer features and how to interconnect them. The features includes the CPU, memory, Input/Output device. To see other definitions or mean… Read More
  • Basic Computer Assignment & Termination OperationsAssignment and Termination operations is a tutorial that will teach you the basic of how data are being kept or stored in a computer memory using the computer assignment instruction(s) and how to stop make a computer doing a … Read More
  • Lagrange's Interpolation Polynomial in Java formIn my previous post, I made the algorithm that solve the Lagrange’s interpolation polynomial, very simple to understand. The algorithm was explained in a such a way that one  can develop a programme from the algorithm us… Read More
  • Computer Architecture | is it Hardware or Software Is computer architecture hardware or software or neither hardware nor software? Computer architecture is the study that deals with analysis, design and configuration of computer system and what feature should be included. … Read More
  • Lagrange’s Interpolation Polynomial AlgorithmSome folks out there find it difficult to understand the Lagrange's algorithm for interpolation polynomial. In this post, I have redeveloped the algorithm in such a format that you will understand and easily implement it in a… Read More

0 comments:

Leave a Reply

All Posts

Access all posts here!

Categories

Unordered List

Sample Text

Lists of Jobs in the United States

List of Courses & Outlines For UNN Students

Popular Posts

Like us on Facebook

Recent Posts

Text Widget