USING ONLY CODE BLOCKS C Please write the program bellow Ple
USING ONLY CODE BLOCKS C++
 
 Please write the program bellow:
 
 Please use the SHELL at the end of this page......
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.
You must use functions for the reading of the data, computing the average, printing the three column table and printing the values above average.
Demonstrate your output in lab.
Submit your source code and algorithm or flowchart in blackboard.
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.
----------------------------------------------------------------------------------------------------------------------
#include <iostream>
 #include <fstream>
 using namespace std;
 void readdata(ifstream &fx, int abc[], int &ct);
int main()
 { int x[30] = {0}, y[30] = {0};
 int ctx = 0, cty =0;
 ifstream f1 (\"h:\\\\datax.txt\",ios::in);
 ifstream f2 (\"h:\\\\datay.txt\",ios::in);
readdata(f1,x,ctx);
readdata(f2,y,cty);
 f1.close();
 f2.close();
return 0;
 }
 void readdata(ifstream &fx, int abc[], int &ct)
 {
      ct = 0; cout<<\"\ \ \";
        while (fx>>abc[ct], !fx.eof())
        {    cout<< abc[ct]<<\"\  \";
          ct++;
         }
    cout << \" \ \ \";
Solution
#include <iostream>
#include <fstream>
#include<math.h>
using namespace std;
/*functions used are read data to get the data from text files
and avg is used to find average of last array above is used to find the values in array z which are more than average
display is used to print 3 column table and small is used to print smallest value in each array*/
void readdata(ifstream &fx, int abc[], int &ct);
float avg(float av,int ctx);
void above(int z[],int ctx,float aver);
void display(int z[],int x[],int y[],int ctx);
void small(int x[],int y[],int z[],int ctx);
int main()
{
int x[30] = {0}, y[30] = {0},z[30]={0};
//ctx and cty used for counting
int ctx = 0, cty =0,i=0;
float aver=0.0f,sqr=0.0f,av=0.0f;
ifstream f1 (\"E:/datax.txt\",ios::in);
ifstream f2 (\"E:/datay.txt\",ios::in);
//calling functions for reading data
readdata(f1,x,ctx);
readdata(f2,y,cty);
for(i=0;i<ctx;i++)
{
z[i]=x[i]*y[i];
}
display(z,x,y,ctx);
for(i=0;i<ctx;i++)
{
av=av+z[i];
}
cout<<\"square root is\"<<sqrt(av)<<\"\ \";
aver=avg(av,ctx);
cout<<\"average is\"<<aver<<\"\ \";
for(i=0;i<ctx;i++)
{
av=av+z[i];
}
above(z,ctx,aver);
small(x,y,z,ctx);
f1.close();
f2.close();
return 0;
}
void readdata(ifstream &fx, int abc[], int &ct)
{
ct = 0; cout<<\"\ \ \";
while (fx>>abc[ct], !fx.eof())
{ cout<< abc[ct]<<\"\ \";
ct++;
}
cout << \" \ \ \";
}
//average function
float avg(float av,int ctx)
{
av=av/ctx;
return av;
}
//function used to print the above values
void above(int z[],int ctx,float aver)
{
int i=0;
cout<<\"\ \"<<\"values more than average\";
for(i=0;i<ctx;i++)
{
if(z[i]>aver)
{
cout<<\"\ \"<<z[i];
}
}
}
//function display is used to print the three column table
void display(int z[],int x[],int y[],int ctx)
{
int i=0;
for(i=0;i<ctx;i++)
cout<<x[i]<<\"\\t\"<<y[i]<<\"\\t\"<<z[i]<<\"\ \";
}
//small function
void small(int x[],int y[],int z[],int ctx)
{
int smal,i=0;
smal=x[0];
for(i=0;i<ctx;i++)
{
if(x[i]<smal)
{
smal=x[i];
}
}
cout<<\"\ \"<<\"small value in x array is\"<<smal;
smal=y[0];
for(i=0;i<ctx;i++)
{
if(y[i]<smal)
{
smal=y[i];
}
}
cout<<\"\ \"<<\"small value in y array is\"<<smal;
smal=z[0];
for(i=0;i<ctx;i++)
{
if(z[i]<smal)
{
smal=z[i];
}
}
cout<<\"\ \"<<\"small value in z array is\"<<smal;
}





