Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MUST USE CODE BLOCKS !!! Write a program to read N data items into two arrays, X and Y , of size 30. Store the

MUST USE CODE BLOCKS !!!

Write a program to read N data items into two arrays, X and Y, of size 30. Store the product of the corresponding pairs of elements of X and Y in a third array Z, also of size 30. Print a three column table that displays the arrays X, Y, and Z. Then compute and print the square root of the sum of the items in array Z. Compute and print the average of the values in array Z and print all values above the average of array Z. Determine the smallest value in each array using only one function.

Use the two data files named DATAX.TXT and DATAY.TXT.

DATAX.TXT

10 5 6 7 23 34 52 6 8 9 11 22 44 11 50 15 12 13 17 31 

DATAY.TXT.

13 51 61 7 12 33 52 16 18 19 10 22 4 13 5 17 12 13 14 31 You must use functions for the reading of the data, computing the average, printing the three column table and printing the values above average. 

All values must be clearly labeled in the output.

You are required to demonstrate your output in Lab.

Documentation will be 20% of your grade.

Your source code must contain the following documentation.

Header information: (Source Code and Output)

Your Name, course & section number, assignment number and due date.

A brief description of your assignment.

Variable dictionary: A brief description of every variable used in your program.

Comments related to input and output of data and all formulas used in your code.

shell

#include  #include  using namespace std; void readdata(ifstream &fx, int abc[], int &ct); int average ( int total , int ct) { return total / ct; } int main() { int x[30] = {0}, y[30] = {0},z[30] = {0}; int ctx = 0, cty =0, total = 0; ifstream f1 ("h:\\datax.txt",ios::in); ifstream f2 ("h:\\datay.txt",ios::in); readdata(f1,x,ctx); readdata(f2,y,cty); cout<<" header "; for ( int i = 0; i < ctx; i++) { z[i] = x[i] * y[i]; cout<< " "<>abc[ct], !fx.eof()) { cout<< abc[ct]<<" "; ct++; } cout << " "; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions