Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ____ __ __
- / / \ / \
- / / /
- / \___/ \___/
- Date: 10/19/17
- Name: Rebecca Lewis
- Project Description: Hw #7 Problem 3;
- Inputs:
- Outputs:
- */
- //*************************************************************
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <iomanip>
- using namespace std; //introduces namespace std
- //Function Prototypes
- double Average(double [], const int);
- int main (void)
- {
- int num_terms=0, x, above_average=0, below_average=0;
- const int size=100;
- double A[size], average;
- cout<<"Please enter the scores (use a negative number to indicate all scores are entered): " <<endl;
- do
- {
- x=1;
- for(int i=0; i<=num_terms; num_terms++)
- {
- cin>>A[num_terms];
- if(num_terms<0)
- {
- x=-1;
- A[num_terms]-=A[num_terms-1];
- }
- }
- }
- while(x>0);
- average=Average(A,num_terms);
- if(int i=0; A[i]>=average; above_average++)
- {
- above_average++;
- }
- if(int i=0; A[i]<average;below_average++)
- {
- below_average++;
- }
- cout<<"There are" <<above_average <<"terms above or equal to the array average."<<endl;
- cout<<"There are" <<below_average <<"terms below the array average."<<endl;
- return 0;
- }
- //Function allows each element in an array to be added and stored as
- //the variable sum.
- double Average(double A[], const int size)
- { int sum, average;
- for(double i=0; i<size; i++)
- sum+=A[i];
- average=sum/size;
- return average;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement