Thread: "the variable ' ' is being used without being initialized" please help and thanks :)

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    9

    "the variable ' ' is being used without being initialized" please help and thanks :)

    "the variable ' ' is being used without being initialized" please help and thanks :)-ssss-jpg
    Attached Files Attached Files

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    People on here don't like downloading stuff from attached files, so it might be better to just use code tags

    [code]
    Your code goes here...
    [/code]


    And is looks like this:
    Code:
    Your code goes here...
    'i' doesn't have to be in brackets for you declaration, nor the 0 after the return statement - That shouldn't cause a problem though

    Can you be more specific about what the problem is?
    Fact - Beethoven wrote his first symphony in C

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    On second thoughts, you are declaring 'i' twice.

    Maybe you want something like this
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main(void)
    {
        int i;
        int fi[100];
            fi[0]=1;
            fi[1]=1;
    
    
        for(i = 2; i<47; i++)
        {
            fi[i] = fi[i-1] + fi[i-2];
            printf("%d\n", fi[i]);
        }
        return EXIT_SUCCESS;
    }
    Note that fi[46] overflows.
    Fact - Beethoven wrote his first symphony in C

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    9
    i am trying to get it to look like

    1,1,2,3,5,8,13,21,etc...

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    9
    sorry im really new to this :/

  6. #6
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Did you try the code that I put up?
    Fact - Beethoven wrote his first symphony in C

  7. #7
    Registered User
    Join Date
    Nov 2012
    Posts
    9
    yes and i thank you for that but i would also like it to stop at 100.

  8. #8
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    You are going to need a larger variable than int then

    Perhaps an unsigned 64 bit variable

    [edit]Hmm... Maybe that is not big enough as well[/edit]
    Fact - Beethoven wrote his first symphony in C

  9. #9
    Registered User
    Join Date
    Nov 2012
    Posts
    9
    i got it thank you for your help. you got me in the right direction and finished it.

  10. #10
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Looks like you are going to need to create your own adding function that can handle big numbers
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Templated BST "Already Initialized" Error
    By misterpogos in forum C++ Programming
    Replies: 5
    Last Post: 10-23-2011, 06:43 AM
  2. Replies: 10
    Last Post: 09-02-2011, 06:15 AM
  3. C++: Variable not initialized within "while" loop
    By iceburg_2487 in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2011, 11:17 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM