If you're programming in C++ past the year 1998, you should be using standard headers. Of course, some compilers in common use are not standard, but it really should be:
#include <iostream>
#include <cmath>
using namespace std; // let's go easy at first
The main function should be declared as returning an int and actually return an int.
int main()
{
// other stuff
return 0;
}
Your variable declarations are almost right. You only need one n, right? I changed p to i just because its a more common idiom and I'm old and set in my ways.
int x[25], y[25], z[25], i, n, sum = 0;
(And you can have them on separate lines.)
You will first ask for the number of loop iterations.
do
{
cout << "How many items (no more than 25)? ";
cin >> n;
} while ( n < 0 || n > 25 );
Using the do ... while loop just keeps asking the question if the value of n is out of range. Note that this doesn't do much for error checking.
So then you've got a valid n, this will be the number of times you loop.
for ( i = 0; i < n; ++i )
{
// yet to come
} What you're doing in this loop is asking for the x and y values.
cout << "x[" << i << "] ? ";
cin >> x[i];
cout << "y[" << i << "] ? ";
cin >> y[i];
You can do the calculation in the same loop, maybe adding some debugging statements.
z[i] = x[i] * y[i];
cout << "z[" << i << "] = " << z[i] << '\n';
sum += z[i] + x[i] + y[i];
cout << "sum = " << sum << endl;
Then when the loop is complete you can calculate the final result.
cout << "result = " << sqrt(sum) << endl;