Question

U CHU PO J O ! Week 11 Homework-Functions X + /bbcswebdav/pid-2592362-dt-content-rid-39864984_1/courses/CSC-170-03-191/CSC%20
Week 11 & 12: Value Returning x CSC 170 Program 5 & 6.pdf * Week 11 Homework--Functions x + /bbcswebdav/pid-2592362-at-conten
bcswebdav/pid-2592429-dt-content-rid-39866610_1/courses/CSC-170-03-191/Week%2011%20Homework--Functio CSC 170-03 Week 11 Homew
bcswebdav/pid-2592429-dt-content-rid-39866610_1/courses/CSC-170-03-191/Week%2011%20Homework--Functio CSC 170-03 Week 11 Homew

c++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note : I developed 2 programs. I also develop and update rest of two programs.thank u

_______________________________

Program#5)

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;

void readData(int scores[],int SIZE);
void calcSumAvg(int scores[],int SIZE,int &sum,double &avg);
void printResults(int sum,double avg);
int main() {
   int sum;
   double avg;
const int SIZE=5;
int scores[SIZE];
readData(scores,SIZE);
calcSumAvg(scores,SIZE,sum,avg);
printResults(sum,avg);
   return 0;
}
void readData(int scores[],int SIZE)
{
   for(int i=0;i<SIZE;i++)
   {
       cout<<"Enter Test Score#"<<(i+1)<<":";
       cin>>scores[i];
   }
}
void calcSumAvg(int scores[],int SIZE,int &sum,double &avg)
{
   for(int i=0;i<SIZE;i++)
   {
       sum+=scores[i];
   }
   avg=((double)sum)/SIZE;
}
void printResults(int sum,double avg)
{
   cout<<"Sum of test scores :"<<sum<<endl;
   cout<<"Average :"<<avg<<endl;
}

_________________________

Output:

C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\ReadTestScoresCalculateTotalAverageDisplay.exe Enter Test Score#1:56 Enter Test Sc

______________________________

Program 6)

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;

void readData(int scores[],int SIZE);
int calcSum(int scores[],int SIZE);
double calcAvg(int sum,int SIZE);

void printResults(int sum,double avg);
int main() {
   int sum;
   double avg;
const int SIZE=5;
int scores[SIZE];
readData(scores,SIZE);
sum=calcSum(scores,SIZE);
avg=calcAvg(sum,SIZE);
printResults(sum,avg);
   return 0;
}
void readData(int scores[],int SIZE)
{
   for(int i=0;i<SIZE;i++)
   {
       cout<<"Enter Test Score#"<<(i+1)<<":";
       cin>>scores[i];
   }
}
int calcSum(int scores[],int SIZE)
{
   int sum=0;
   for(int i=0;i<SIZE;i++)
   {
       sum+=scores[i];
   }
   return sum;
}
double calcAvg(int sum,int SIZE)
{
  
       double avg=((double)sum)/SIZE;
   return avg;
}


void printResults(int sum,double avg)
{
   cout<<"Sum of test scores :"<<sum<<endl;
   cout<<"Average :"<<avg<<endl;
}

___________________________

Output:

C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\ReadTestScoresCalculate TotalAverage DisplayCPP.exe Enter Test Score#1:67 Enter Te

___________________________Thank You

Add a comment
Know the answer?
Add Answer to:
c++ U CHU PO J O ! Week 11 Homework-Functions X + /bbcswebdav/pid-2592362-dt-content-rid-39864984_1/courses/CSC-170-03-191/CSC%20170%20Program%205%20%26% CSC 170 -...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please Use C++ for coding . . Note: The order that these functions are listed, do...

    Please Use C++ for coding . . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...

  • IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are...

    IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are developing a program that works with arrays of integers, and you find that you frequently need to duplicate the arrays. Rather than rewriting the array-duplicating code each time you need it, you decide to write a function that accepts an array and its size as arguments. Creates a new array that is a copy of the argument array, and returns a pointer to the...

  • A. File I/O using C library functions File I/O in C is achieved using a file...

    A. File I/O using C library functions File I/O in C is achieved using a file pointer to access or modify files. Processing files in C is a four-step process: o Declare a file pointer. o Open the desired file using the pointer. o Read from or write to the file and finally, o Close the file. FILE is a structure defined in <stdio.h>. Files can be opened using the fopen() function. This function takes two arguments, the filename and...

  • I need help with this assignment in C++, please! *** The instructions and programming style detai...

    I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...

  • ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions...

    ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions -Learn to use reference variables Coding Guidelines for All Labs/Assignments (You will be graded on this) -Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). -Keep identifiers to a reasonably short length. -Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables,...

  • C++ For this assignment you will be building on the Original Fraction class you began last...

    C++ For this assignment you will be building on the Original Fraction class you began last week. You'll be making four major changes to the class. [15 points] Delete your set() function. Add two constructors, a default constructor that assigns the value 0 to the Fraction, and a constructor that takes two parameters. The first parameter will represent the initial numerator of the Fraction, and the second parameter will represent the initial denominator of the Fraction. Since Fractions cannot have...

  • Write a program in C++ that simulates a soft drink machine. The program will need several...

    Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...

  • I keep getting an error code in my C++ program. It says "[Error] 'strlen' was not...

    I keep getting an error code in my C++ program. It says "[Error] 'strlen' was not declared in this scope" in my main.cpp. Here are my codes. main.cpp #include <iostream> #include <string> #include "functions.h" using namespace std; //definition of the main function. //takes arguments from the command-line. int main(int argc, char *argv[]) { //Determine if you have enough arguments. //If not, output a usage message and exit program if (argc<2 || (argc == 2 && argv[1][0] == '-')) { //call...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT