Algorithm and Flowchart to Compute Average of Three Numbers

[27598 views]


What is Average?

Average is a mathematical term used in taking the appropriate number among the list of numbers. Formula for Average = Sum of all values / No. of values in the list.

What is Average used for?

There are various scenarios in which we have to say a single value of things. For that instance we use average number for single value. For Eg. If in a batsman scores 20 runs in 1st match, 37 runs in 2nd match and 78 runs in third match. So we can say Average of the batsman is (20+37+78)/3=45. It says that the batsman can score around 45 runs in a match. Here, we can see that we are converting multiple values into single value to make things easier.

So in Conclusion I will be reading three numbers and finding average of them by adding the numbers and then dividing the sum with 3.

Flowchart for Average of three numbers

Flowchart for Average of three numbers
Remove WaterMark from Above Flowchart

Algorithm for Average of three numbers

Declare a variable a,b,c and avg as int; Read two numbers a,b and c; avg=(a+b+c)/3; Print avg;

Here in this algorithm we declare 4 variables as integers. Three variables for input one variable to store the result. We input two numbers lets say 15 , 20 and 25.In the program we compute average by sum of these numbers i.e.. 15+20+25=60 and dividing it with 3 i.e.. number of values. Therefore the result 20 get stored in avg and at last we print the value.

Implementation of Average of 3 numbers in C:

#include<stdio.h> int main() { int a, b, c, avg; //Declaring the variables printf("Enter three variables:\n"); printf("a:"); scanf("%d", & a); //Reading Variable a printf("b:"); scanf("%d", & b); //Reading Variable b printf("c:"); scanf("%d", & c); //Reading Variable c avg = (a + b + c) / 3; printf("\nAverage of %d,%d and %d is %d", a, b, c, avg); }

Output of the program

        

Having Difficulty understanding above Algorithm and Flowchart? Buy Our Notes



Are You Good enough in Algorithms? Test your Skills


Comments



Search
Recommended Deals










Recommended Quiz
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Algorithm for Average of three numbers

    Flowchart for Average of three numbers

    C program for Average of 3 numbers