Search C++ Programs and Tutorials

Friday, November 4, 2011

Program Average Algorithm and Flowchart

Leave a Comment

Q: Write a program to input three numbers, and calculate and show their average

Today, we will discuss a simple C++ program that inputs three numbers and calculates and shows average of these numbers.

Algorithm: Average

Calculates average of three numbers.

1. Start
2. Include iostream.h [Note: this step is only for C++].
3. Declare 5 float variables n1,n2,n3, total and avergae.
4. Display a message (prompt) on screen "Enter First Number:"
5. Input n1.
6. Display a message (prompt) on screen "Enter Second Number:"
7. Input n2.
7. Display a message (prompt) on screen "Enter Third Number:"
8. Input n3.
9. Calculate total= n1 + n2 + n3
10. Calculate average = total / 3
11. Show a message "Average=" and value stored in average variable.
12. Stop


C++ Program To Calculate Average of Three Numbers Input by User at Run time
C++ Program To Calculate Average of Three Numbers Input by User at Run time

Simple C++ Program To Calculate Average of Three Numbers With Algorithm and Flow chart
Simple C++ Program To Calculate Average of Three Numbers With Algorithm and Flow chart 

Program Source Code : C++ Program To Calculate Average of Three Numbers With Algorithm and Flow chart

#include<iostream.h>

int main()

{

float n1,n2,n3,total,average;

cout << "Enter First Number:";

cin>>n1;

cout<<"Enter Second Number:";

cin>>n2;

cout<<"Enter Third Number:";

cin>>n3;

total=n1+n2+n3;

average=total/3;

cout<<"average="<<average;

return 0;

}
If You Enjoyed This, Take 5 Seconds To Share It