|
-
March 30th, 1999, 08:26 AM
#1
Whats wrong with this code????
This code is supposed to ask the user
How many numbers would you like to enter?
And then give the smallest, largest , average, and the difference
between each number and the average. But it wont work. And i cant find
why. I get no error but it still wont work.
Could you please help me fix this thing as I have no more hair left
thinking about it. I am new to programming so I need the most basic
code to fix it....
I thank you in advance..
Ercan
#include <iostream.h>
#include <conio.h>
main()
{
clrscr();
int maxentries,maxnumber,minnumber,number,totalaverage;
float average,sum,difference;
cout<<"How many Numbers would you like to Enter?\t";
cin>>maxentries;
for (int count = 0; count < maxentries; count++)
{
cout<<"\n\nEnter a number Please:\t";
cin>>"number";
sum += number;
average = ( sum / count );
cout<<"\nAverage of these numbers is\t"<<average;
difference = ( number - average );
cout<<"\nDifference between this number and the average is"<<difference;
if ( number < minnumber )
minnumber = number;
if ( number > maxnumber )
maxnumber = number;
}
cout<<"\nSmallest number is\t"<<minnumber;
cout<<"\nLargest number is\t"<<maxnumber;
totalaverage = sum / maxentries;
cout<<"\nTotal average is\t"<<totalaverage;
getch();
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|