English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

for example the numbers are a ,b,c

2006-06-11 08:21:10 · 2 answers · asked by hiwot4life2 1 in Computers & Internet Programming & Design

2 answers

==================
#include

int main(void)
{

int count; // holds the count
float sum, number, avg;

sum = 0.0;
count = 0;

cout << endl << endl // Make some space
<< endl << "Enter a number. Enter a zero (0) when you have"
<< endl << "finished entering numbers and want to compute the"
<< endl << "average of the inputted numbers." ;

do {
cout << endl << endl << "Data element #" << count + 1
<< ": ";

cin >> number;

if (number != 0.)
sum = sum + number;
count = count + 1;

} while (number != 0.0);

averg = sum / (count-1);
cout << endl << "The average is: " << avg
<< endl << endl ;
return 0;
}


==================

This program computes the average of a set of data values. Commented a bit for you to understand

Enjoy

2006-06-11 08:40:29 · answer #1 · answered by ? 6 · 0 0

#include
#include
#include

void main()
{
clrscr();
int a,b,c,sum;
float average;
cout << "Enter 3 integers : " << endl;
cin>>a>>b>>c;
sum=a+b+c;
average=sum/3;
cout << "The sum of is " << sum << "." << endl;
cout << "The average is " << average << "." << endl;
getch();
}

2006-06-11 15:42:19 · answer #2 · answered by Sean I.T ? 7 · 0 0

fedest.com, questions and answers