Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need program #2.. This should be the code for Part 1. #include #include using namespace std; //to calculate the average of the grades, minimum

I need program #2..

image text in transcribed

This should be the code for Part 1.

#include #include using namespace std;

//to calculate the average of the grades, minimum of the four assignments, //and the maximum of the four assignments. void ProcessRow(int *data) { int minVal,maxVal,sum=0,j,avg; minVal=maxVal=*(data+1);

for( j=1; j*(data+j)) minVal=*(data+j); if(maxVal

} avg=sum/(j-1); *(data+j)=minVal; *(data+(j+1))=maxVal; *(data+(j+2))=avg;

}

int main() {

int data[3][8]; ifstream file("data.txt"); cout

//to read data from file for(int i = 0; i > data[i][j];

ProcessRow(&data[i][0]);

} //to print the output for(int i = 0; i

}

return 0; }

Program 1: (Practicing an example of function using call by reference) Write a program that reads a set of information related to students in C++ class and prints them in a table format. The information is stored in a file called data.txt. Each row of the file contains student number, grade for assignment 1, grade for assignment 2, grade for assignment 3, and grade for assignment 4. Your main program should read each row, pass the grades for the three assignments to a function called ProcessRow to calculate the average of the grades, minimum of the four assignments, and the maximum of the four assignments. The results (average, maximum, and minimum) should be returned to the main program and the main program prints them on the screen in a table format. For example, if the file includes 126534 321345 324341 10 7 4 your program should print Std-Id A1A2 A3A4Min Max Average 126534 321345 324341 10 7 4 10 8 You must use call by reference to do the above question. Program 2: (Practicing an example of function using call by value) Repeat the above question using call by value. This means you need to have three different functions: one to calculate the average, another to calculate the minimum, and the third one to calculate the maximum. This is how to call these functions: Max = CalculateMax(A 1 ,A2,A3, A4); Min-CalculateMin(A1,A2,A3, A4); Average = CalculateAvg(Al ,A2,A3, A4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

How would you describe your typical day at work?

Answered: 1 week ago