Thread: array array and more arrays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    41

    array array and more arrays

    I want to print the following prices to screen:
    10.95 16.32 12.15
    8.22 15.98 26.22
    13.54 6.45 18.59

    here is the code
    Code:
    #include <stdio.h>
    int main()
    {
    #define NUMROWS 3
    #define NUMCOLS 3
      float prices[NUMROWS] [NUMCOLS] = {10.95, 16.32, 12.15, 8.22, 15.98, 26.22, 13.54, 6.45, 18.59};
      int i, j;
    
         printf("\n%.2f %.2f %.2f", prices[0][0], prices[0][1], prices[0][2]);
         printf("\n%.2f %.2f %.2f", prices[1][0], prices[1][1], prices[1][2]);
         printf("\n%.2f %.2f %.2f", prices[2][0], prices[2][1], prices[2][2]);
         for (i = 0; i < NUMROWS; i++)
           {
    	 printf("\n");
    	 for (j - 0; j < NUMCOLS; j++)
    	 printf("%.2f ", prices[i][j]);
           }
         printf("\n");
    
         return 0;
    }
    sorry, i got it
    Last edited by wonderpoop; 12-20-2006 at 06:09 PM.

Popular pages Recent additions subscribe to a feed