Thread: Declaring Variables for Arrays~ Newbie Question

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    6

    Declaring Variables for Arrays~ Newbie Question

    I just wanted to know if these are appropriate declarations
    digits is an array of 10 integers = int digits [10]
    rates is an array of 6 floats = float rates [10]

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    digits is good, rates isn't.

  3. #3
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    Code:
    int digits[10];
    double rates[6];
    But make sure you know 10 and 6 is how many, not the size.
    And that start indexing at 0.
    So you have digits[0] through digits[9].

    Code:
    //declared earlier
    
    digits[0] = 555; //First value in array gets 555
    digits[9] = 323; //Last value in array gets 323
    rates[4] = 99.99; // 5th value in rates array gets 99.99

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie: array question :(
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-09-2008, 06:46 AM
  2. Total Newbie Question
    By Kid A in forum C++ Programming
    Replies: 4
    Last Post: 06-22-2006, 05:36 AM
  3. Newbie Question integers and variables
    By MrMe in forum C Programming
    Replies: 9
    Last Post: 05-25-2006, 04:22 AM
  4. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 12:13 PM
  5. Question about variables
    By BongoBob in forum C++ Programming
    Replies: 3
    Last Post: 03-01-2006, 11:20 PM