Computer Science, asked by baby4905, 8 months ago

Prepare algorithm for 1. for i=o and 1=4,
1.1. get the num [I]
1.2. sum= sum+ num[I]
2. Average = sum/5 3. Print Sum
4. Print Average

Answers

Answered by devanshdixit456
0

Explanation:

How do I write an algorithm that calculate the sum and average of all even numbers between 1 and 50?

Ad by PrepBytes

Is PrepBytes really helpful?

The answer is Yes. At present, I am enrolled into 100 day Expert Coder course and I am finding it really Helpful. They are prep...

Continue Reading

12 Answers

Akhilesh Kumar, MCA Computer Science, Galgotias University (2019)

Answered Apr 27, 2018

Algorithm : →

Step 1 : Start

Step 2 : sum = 0, i = 1, average, count = 0

Step 3 : if i / 2 == 0 then go to step 4, else go to on step 5

Step 4 : sum = sum + i, count = count + 1

Step 5 : i = i + 1

Step 6 : if i <= 50 then go to on step 3, else go to on step 7

Step 7 : Display “sum”

Step 8 : average = sum/count

Step 9 : Display “average”

Step 10 : Stop

—————————————————————————————————————

Alternative : →

Step 1 : Start

Step 2 : sum = 0, i = 0, average, count = 0

Step 3 : i = i + 2

Step 4 : sum = sum + i, count = count + 1

Step 5 : if i <= 50 then go to on step 3, else go to on step 6

Step 6 : Display “sum”

Step 7 : average =sum/count

Step 8 : Display “average”

Step 9 : Stop

14.2k views · View 7 Upvoters

RELATED QUESTIONS (MORE ANSWERS BELOW)

How do I find an algorithm to find the sum and average of 10 numbers?

5,525 Views

What algorithm can I use to calculate the average of five numbers?

1,977 Views

How do I write an algorithm that calculate the sum and average of all odd numbers between 1 and 50?

1,007 Views

What is the algorithm to find the average of the numbers 1 to 10?

13,545 Views

How do you write an algorithm to find the sum of the first 50 numbers?

56,341 Views

OTHER ANSWERS

Kalani Tharaka, Software Engineer (R&D) (2020-present)

Answered Mar 15, 2020

n=1

sum = 0

Check whether the n is even

If n is even, sum = sum + n

n = n + 1

If n < 50 , return to step 3

Stop

495 views · View 1 Upvoter · Answer requested by Pratik Patil

Sponsored by Dell

If you are a small business, we are here to help.

A Dell advisor is standing by, ready to get you the technology solutions you need.

Learn More

Rahul Dey, lived in Kolkata, West Bengal, India

Answered Apr 27, 2018 · Author has 459 answers and 320.6k answer views

There are 25 even numbers between 1 and 50 (both inclusive). The first even number is 2 and the last one is 50. Using the sum of an arithmetic series formula this problem can be solved very easily.

sum of ap = n/2(a + l) where n is the number of terms in the AP and a and l are the first and last term.

So the code would look like this in c/c++ and with little modificaiton in java as well.

int main() {

int n = 25, a = 2, l = 50;

int sum = (n * (a + l))/2;

int average = sum/n;

//printing code goes here

return 0;

}

2.4k views · View 2 Upvoters

Neil Gupta, In Calculus AB

Answered Apr 28, 2018 · Author has 869 answers and 694.4k answer views

sum = 0

n = 0

i = 2

while i < 50:

sum += i

n += 1

i += 2

print 'sum: {}'.format(sum)

print 'avg: {}'.format(float(sum) / n)

5k views

Sponsored by Amazon India

Scan & pay on Amazon.

Go safe, go contactless. Make payments using scan and pay with Amazon! Try now.

Learn More

RELATED QUESTIONS (MORE ANSWERS BELOW)

What is the algorithm to display odd numbers from 49 to 1?

3,065 Views

How do I write an algorithm for the average of two numbers?

5,063 Views

What is the algorithm to calculate the sum of 3 numbers?

483 Views

What is the algorithm to find sum and average of 'n' numbers in an array?

8,134 Views

What is an algorithm to find the average of four numbers?

4,156 Views

OTHER ANSWERS

Lukas Schmidinger, I have passed some math courses in university.

Answered Apr 27, 2018 · Author has 14.7k answers and 3.2m answer views

The sum of all even numbers from 11 to nn is

2×∑k=1

Similar questions