Tuesday, August 16, 2011

Average of three numbers

Problem: Find average of three numbers.


Algorithm:
1. Prompt for three numbers.
2. Calculate average by the formula.
3. Display the result.

Source Code:
#include<iostream>
#include<conio.h>
using namespace::std;
int main (void)
{
int num1;           //first number
int num2;          //second number
int num3;          //third number
int average;      //average
cout<<"Enter the first number ";
cin>>num1;
cout<<"Enter the second number ";
cin>>num2;
cout<<"Enter the third number ";
cin>>num3;
average=(num1+num2+num3)/3;         //formula for finding average
cout<<endl<<"Average of given three numbers is ";
cout<<average<<endl;
getch();
return 0;
}

0 response(s):

Respond to this Post

Your participation is appriciated...