Thread: Help needed for c programming only

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    30

    Help needed for c programming only

    I have study a book of C programming and it shows answer for the question but i cannot get back the answer that show in the book. The output is
    Code:
    values[0] = 197
    values[1] = 0
    values[2] = -101
    values[3] = 547
    values[4] = 0
    values[5] = 350
    values[6] = 0
    values[7] = 0
    values[8] = 0
    values[9] = 35
    The answer for the code to produce the output is
    Code:
    #include <stdio.h>
    int main (void)
    {
    int values[10];
    int index;
    values[0] = 197;
    values[2] = -100;
    values[5] = 350;
    values[3] = values[0] + values[5];
    values[9] =
    values[5] / 10;
    --values[2];
    for ( index = 0; index < 10; ++index )
    printf ("values[%i] = %i\n", index, values[index]);
    return 0;
    }
    Can someone help me??
    I am using the c free standard

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    Some of the elements in the values array are never initialized, so they can be anything when you print them. For example, values[1] is never initialized to anything, so printing that element can result in any random number depending on your compiler, OS and what was in that memory location before.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DIfference between , and ;
    By rocketman03 in forum C++ Programming
    Replies: 6
    Last Post: 10-21-2009, 09:46 AM
  2. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  3. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM

Tags for this Thread