Hey guys, i am working on a program and it deals with arrays. Basicaly its a conversation program i am working on. I have alot of it done but i am stuck with the displayiong of the info. Now being this is an assignment i would really like advices and tips that i should look or maybe explanations. If you guys have any tips please lemme know.

#include <stdio.h>
#include <stdlib.h>
//#include <iomanip.h>

const int MAX_CURRENCYS = 100;          /* Max number of dollar Deposits 100$ */
const float DOLLARS_TO_YEN = 102.2;   /* 1 Dollar = 102.2 Yen this is the value of the yen*/


/* Function declarations */
void readDollars ( float Dollars[], int count );
void DollarsToYen ( float Dollars[], float Yen[], int count );
void displayData ( float Dollars[], float Yen[], int count );

int main (void)
{
    int nums;               // input the number of deposit */
    float Dollars[MAX_CURRENCYS],    /* Dollars value the user wishes to put in his accounts*/
           Yen[MAX_CURRENCYS];      /* Yen value the user wishes to put in his accounts*/

    /* Prompt the user for the number of deposits. */
    printf("\n Enter the number of  deposits: ");
    scanf("%d", &nums);

    // Read the amount in each deposit .
    readDollars(Dollars,nums);

    // Convert Dollars to Yen.
    DollarsToYen (Dollars, Yen, nums);

    // Display the amount in each deposit
    displayData(Dollars,Yen,nums);
}

/* read number of Dollars in each  account from the keyboard */

void readDollars ( float Dollars[], int count )
{
   int j;
   printf("Enter the  dollar amount for each : ");
   for ( j=0; j < count; j++ )
       scanf("%f",&Dollars);
}

/*gives number of Yen in each account */

void DollarsToYen ( float Dollars[], float Yen[], int count )
{
    int j;
    for (; j < count; j++)
    Yen = Dollars * DOLLARS_TO_YEN;
    printf("","The conversion of $ to y is %10.2f\n",Yen);

}

/* displays the amount in each account in both Dollars and Yen */

void displayData ( float Dollars[], float Yen[], int count )
{
    int j;
    printf("\n      Dollars     Yen     \n");
    for (; j < count; j++)

        printf("   %7f     %12f \n", Dollars, Yen );
    }

The program was running before but my error occurs on the hilighted line. it says invalid operations to binary.
If i finish it in the meantime i will post my results! Thanks For any tips given

oops sorry lol it says invalid operands to binary. operands ..operations same thing :)

In this code:

void DollarsToYen ( float Dollars[], float Yen[], int count )
{
    int j;
    for (; j < count; j++)
    Yen = Dollars * DOLLARS_TO_YEN;
    printf("","The conversion of $ to y is %10.2f\n",Yen);

}

Dollars is an array, and you shouldn't be trying to multiply that address at all. You want:

Yen = Dollars[j] * DOLLARS_TO_YEN;

But you need to initialize j = 0, in the for loop.

You also need to initialize j = 0 in the for loop of displayData

SOunds good i will give it a try right now , thanks for the tips fellaz

well i have i incorporated the j=0 to both the areas that were missing it ( its weird my professor was ademant that i remove it). ANyway now, that i tried your formula Adak

Yen = Dollars[j] * DOLLARS_TO_YEN;

I get an error that says Incompatible types in assignment. I googled it in order to figure what it meant but no clear answers.

Oops, he forgot and I didn't notice that Yen has the same problem as Dollars had. Basically they are both arrays but you were not telling the program which element to access.

So it should probably be Yen[j] = Dollars[j] * DOLLARS_TO_YEN;

As for why your professor was adamant that you remove j=0 before the for loops, perhaps he just didn't like you.

hhahah thanks N1ghts, that took care of that problem, Now i am just going to look at the display area, as that is not pulling the data, thanks guys i aprreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.