I do not know if I should use a 2D or just two seperate arrays to make this easier.

I have two arrays. One is just an array like {1,2,3,4...n} and the other has values that correspond to those and make pairs.

I want to create an array that stores the slopes of the points.
m[n/2] would have m[0] the slope from the first two points and m[1] has slopes from point 2-3 and so on. Basically making segments and taking the slopes of those segments.

I have tried a few things

``````for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
m[i]=((lnnum[j]-lnnum[j+1])/(lnt[j]-lnt[j+1]));
j=j+2;``````

This one of the closest. I get the correct values with every other value in m

``````for (int i=0;i<n;i++)
{
m[i]=((lnnum[i]-lnnum[i+1])/(lnt[i]-lnt[i+1]));
i=i+1;
}``````
1
Contributor
1
3
Views
7 Years
Discussion Span
Last Post by JordanHam
``````for (int i=0, a=0;i<n;i++, a=a+2)
{
m[i]=((lnnum[a]-lnnum[a+1])/(lnt[a]-lnt[a+1]));
}``````

NEVERMIND!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.