I have not done any c++ programming yet but was wondering how you use arrays in a for loop for example the code below

int i;
double D_Nath(11),D(11),er(11);
for( i=0;i < 11; i++)
{
D_Nath(i)=PI*D(i)/er(1)*.76554;
}


how dod you get this to work correctly.

Thanks for any help with this.

Replace the round brackets with square ones [] and you are good to go...Oh and btw it would be a good idea to initialize your arrays.

Replace the round brackets with square ones [] and you are good to go...Oh and btw it would be a good idea to initialize your arrays.

i have tried to change it

int i;
double D_Nath[11],D[11],er[11];
for( i=0;i < 11; i++)
{
D_Nath(i)=PI*D(i)/er(i)*.76554;
}


this is what I have for the code but I am getting a C2064 error in the line with the D_Nath(I)=
any idea what I am doing wrong

i have tried to change it

int i;
double D_Nath[11],D[11],er[11];
for( i=0;i < 11; i++)
{
D_Nath(i)=PI*D(i)/er(i)*.76554;
}

this is what I have for the code but I am getting a C2064 error in the line with the D_Nath(I)=
any idea what I am doing wrong

D_Nath[i]=PI*D[i]/er[i]*.76554;

You forgot to change the () for [] inside statement inside the loop

Edited 3 Years Ago by mike_2000_17: Fixed formatting

`D_Nath[i]=PID[i]/er[i].76554;

You forgot to change the () for [] inside statement inside the loop

Thanks for all your help. it worked great!!.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.