I have prompted the user for 5 inputs in the main and saved them into an array called array. I've checked the array in main and it prints out the values as they were entered. However, when I pass it to a function which I've included below, I get the output that the array contains all 0 values. What am I doing wrong?
conversion(float array[], int size)
{
float add = 0.0;
float change, num;
printf("\nThe array is: \n");
for (i=0;i < size;i++)
{
printf("%.2f\n",&array[i]);
}
/*calculate and store the conversion values in a new array*/
for(i=0; i<s; i++)
{
num = array[i];
change = (num*100.50);
for(j=0; j<1; j++)
{
printf("\n %.2f your number is %.2f in float percent\n", &num, &change);
}
}
}
printf("%.2f\n",&cArray[i]);Remove the&. With it you are passing the address of the variable, when you want to pass the value.