Please Scroll Down to See Forums Below
napsgear
genezapharmateuticals
domestic-supply
puritysourcelabs
UGL OZ
UGFREAK
napsgeargenezapharmateuticals domestic-supplypuritysourcelabsUGL OZUGFREAK

ne c++ programmers in here?

MaGilicuti

New member
taking cs2 and i need some help. fucking lost

HELP!!!!!

right now trying to come up with a program to take a set of scores, average them out and then have it display all scores under the average.
 
nto very hard. what kinda c++ u doing, mfc? or some dummied down set of tools. if ur using iostream.h it will be very easy if ur doing mfc its not much harder but if u have never programmed it is.

the psuedocode is something like this
make sum variable and input (aka +=) values into it, for each value inputted increase a counter variable. then display sum/counter. after that just reread the data and output on screen. not too hard!
 
still need help?
 
well what do you have so far or what is giving you problems?
 
void print_below_avg_scores(int s[ ], int n)
{
int i;
double total = 0, avg;
for(i = 0;i < n; i++){
total+= s;
}
avg = total/n;
for(i = 0; i < n; i++){
if(s < avg)
cout<<s<<endl;
}
}

#include <iostream.h>
int fill_aquire_array(int s[ ])
{
int i;
do
{
cout<<"Enter up to 10 scores.\n";
cout<<"Enter test score:\n";
cin>>s;
cout<<"Are you finished?(Y/N)?\n";
cin>>finish;
s = s++
}
while


its real scrappy, but that's all i have right now
 
Code:
#include "iostream.h"

void
prt_scores(double *s, int count)
{
  double tot;
  int c;

  if (count == 0)
  {
    cout << "There were no scores submitted.\n";
  }
  else
  {
    cout << "The submitted scores were:" << endl;
    for (c = 0; c < count; ++c)
    {
      tot += s[c];
      cout << s[c] << endl;
    }
    double avg = tot / count;
    cout << "The average score was " << avg << endl;
    cout << "The following scores were below average\n";
    for (c = 0; c < count; ++c)
    {
      if (s[c] < avg)
        cout << s[c] << endl;
    }
  }
}

int main(char *argv, int argc)
{
  int count = 0;
  double s[10];

  cout << "Enter upto 10 scores\n";
  cout << "Enter a non-numerical value to finish\n";
  while (count < 10)
  {
    double val = 1010.0101;
    cout << count + 1 << ". Enter Test Score: \n";
    cin >> val;
    if (val == 1010.0101)
    {
      break;
    }
    s[count++] = val;
  }
  prt_scores(s, count);
  return 0;
}
 
Top Bottom