Thread: Help with a Fibonacci

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    3

    Help with a Fibonacci

    Hello,

    I am very new to programming in C and wanted to try to create a program. However, when i try to run the program i get this message unable to read unknown load command 0x80000022.
    Any help would be great

    Code:
    #include <stdio.h>
    
    int main () {
    
    	int fib1;
    	int fib2;
    	int fib3;
    	int numfib;
    	
    	printf("What number would you like to start with?");
    	scanf(fib1);
    	printf("What other number would you like to start with?");
    	scanf(fib2);
    	printf("How many numbers would you like printed?");
    	scanf(numfib);
    	printf("%d, %d", fib1, fib2);
    	for (numfib ;numfib>0 ; numfib--) {
    		fib3=fib1+fib2;
    		printf("%d", fib3);
    		fib1=fib3;
    		fib3=fib1+fib2;
    		printf ("%d", fib3);
    		fib2=fib3;
    	}
    	
    }



    Thanks
    Last edited by Thedog; 01-17-2011 at 05:41 PM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    scanf() tries to read input, and put it at the address you give it. You didn't give scanf() a valid address:

    Code:
    scanf("%d", &yourIntegerVariableNameHere);

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    3
    Thanks that helped but now once my program runs it prints a bunch of numbers that have nothing to do with my code

  4. #4
    Registered User
    Join Date
    Jan 2011
    Posts
    3
    I figured out my problem. Thank you for the help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fibonacci
    By saria777 in forum C Programming
    Replies: 25
    Last Post: 06-16-2010, 07:26 AM
  2. fibonacci prime
    By dbzx in forum C Programming
    Replies: 5
    Last Post: 04-17-2009, 11:13 AM
  3. fibonacci using recursion?
    By n3cr0_l0rd in forum C Programming
    Replies: 12
    Last Post: 02-25-2009, 08:49 AM
  4. Recursive Fibonacci, some help needed
    By cwafavre in forum C Programming
    Replies: 8
    Last Post: 11-04-2007, 02:20 PM
  5. void fibonacci() - Is This Possible?
    By Not Yet in forum C++ Programming
    Replies: 3
    Last Post: 11-25-2002, 10:24 PM