i dont undrstand this array

This is a discussion on i dont undrstand this array within the C Programming forums, part of the General Programming Boards category; i am trying to self teach, but i dont understand this and i hope someone that is kind enought to ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    62

    i dont undrstand this array

    i am trying to self teach, but i dont understand this and i hope someone that is kind enought to explain this to me.

    Code:
    #include <stdio.h>
    #include <stdio.h>
    #include <conio.h>
    int main()
    
    {
    int a[3]= {11,22}, b[]={44,55,66}, i;
    double x[2],y[10];
    
    printf("a[0]=&#37;2d,  a[1]=%2d,   a[2]=%2d  \n"
           "b[0]=%2d,  b[1]=%2d,   b[2]=%2d  \n\n",
            a[0],a[1], a[2] ,b[0], b[1],b[2]);
    
    printf("please enter two real numbers\n");
    scanf("%lf %lf",&x[0], &x[1]);
    printf("x[0] = %.1lf    x[1] = %.1lf\n\n", x[0], x[1]);
    
    for (i=0;i<10;i++)
          {
          y[i]= i*100.0;
          printf("y[%1d]=%.2lf\n", i, y[i]);
          }
          
          getch();
    }
    Last edited by joker_tony; 03-29-2008 at 04:24 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Well it's not going to compile. You've got an n\n", x[0] hanging out loose, and your first printf isn't finished. Your scanf on the x's is wrong (they need to both be %lf, not %1f and not %f). Once you get it running, the program explains itself (that's what all the printf's are for).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Replies: 6
    Last Post: 11-09-2006, 02:28 AM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21