I have to write a program to read N data items into two arrays, X and Y, of size 25.
Surely you can translate that into code.
int X[25];
int Y[25]; Calculate and store the products of corresponding pairs of elements of X and Y in a third array, Z, also of size 25.
Surely you know the declaration.
int Z[25];
And surely you can find the product.
Z[i] = X[i] * Y[i]; Also, compute and print the square root of the sum of the items of the three arrays.
Surely you can sum the elements of Z[] (likely in a loop) and then you can surely find the square root of this sum.
double result = sqrt(sum); Prompt the user for input with N less then 25.
Surely you can prompt the user for a number.
int N;
cout << "prompt: ";
cin >> N;
So, what's the problem? Determining whether N is less than 25? Using a loop? Or trying to put code fragments together in an order that completes the assignment?
Take a shot at it.
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314