Thread: array program help.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    12

    array program help.

    i need some direction on how to do this. i need to take the values in my two arrays and find the product of them and store that into my third array. This is what i have so far.

    Code:
    #include <stdio.h>
    #include <conio.h>
    int main()
    {
        void extend(float [9], float[9] , float[9]);
        float price[9];
        float quantity[9];
        float amount[9];
        
        int i;
        
        
        printf("this program will accept 10 numbers and the quantity\n");
        
        for(i = 0; i < 9; i++)
              {
              printf("Please enter the price:\n");
              scanf("%f", &price[i]);
              printf("Please enter the quantity:\n");
              scanf("%f", &quantity[i]);
              }
        extend(price, quantity, amount);
        
        getch();
        return 0;
    
    
    
    
    }
    void extend(float price[], float quantity[], float amount[])
    {
         int j;
         int h;
         
         for(j = 0; j < 9; j++)
         {
               amount[j] = price[j] * quantity[j];
         }
               
         for(h = 0; h < 9;h++)
         {
               printf("%.2f\n", amount[h]);
         }
    }
    for some reason i keep getting errors.
    Last edited by chumpp; 07-25-2012 at 10:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a array program
    By antim in forum C Programming
    Replies: 2
    Last Post: 03-06-2011, 01:16 PM
  2. Replies: 1
    Last Post: 03-16-2010, 10:17 AM
  3. Help converting array program to link list program
    By hsmith1976 in forum C++ Programming
    Replies: 0
    Last Post: 02-14-2010, 09:50 PM
  4. Array Program
    By emmx in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 12:44 AM
  5. Help with Array Program!
    By ProgrammingDlux in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2002, 01:02 PM