• (2 Pages)
• 1
• 2

## 19 Replies - 954 Views - Last Post: 03 February 2013 - 10:22 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=307381&amp;s=6f529fd3a4e508173a5fe8e8a68f2c3b&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 jjl

• Engineer

Reputation: 1168
• Posts: 4,782
• Joined: 09-June 09

## Re: Question about Fibonacci Sequence.

Posted 20 January 2013 - 02:52 PM

The fibonacci sequence is naturally defined recursively. Maybe if you implement it recurisivly first, then you will understand your problems with your iterative solution.

### #17 raghav.naganathan

• Perfectly Squared ;)

Reputation: 410
• Posts: 1,449
• Joined: 14-September 12

## Re: Question about Fibonacci Sequence.

Posted 20 January 2013 - 09:03 PM

Well, here are some suggestions I have for your code. I have indicated them in comment lines.

```#include<stdio.h>
#include<conio.h>
main()// should be int main()
{
int num=0,a=0,b=1,count=0;

printf("How many number you want? (3minimum):");
scanf("%d",&num);
printf("0\n1");
do {
b=a+b;
a=b-a;
b=a+b-a; //This statement seems to be redundant here as a will get cancelled by -a
count++;
printf("\n%d",b );
}
while(count<=num-3);
printf("\n");
return 0;
}// wrong closing of braces
getch();
//braces must close here

```

regards,
Raghav

### #18 johnpaulbb02

Reputation: -1
• Posts: 11
• Joined: 15-January 13

## Re: Question about Fibonacci Sequence.

Posted 03 February 2013 - 09:48 AM

I created this one:

[
```#include<stdio.h>
#include<conio.h>

main()
{
int x,val;

clrscr();
printf("Enter value:");
scanf("%i",&val);
x=1;
do
{
printf("\n%i",x);
x++;
}
while(x<=val);
getch();

}
```

]

can you help me to insert a code that will add the sequence?

This post has been edited by jimblumberg: 03 February 2013 - 10:00 AM
Reason for edit:: Added missing code tags. Please learn to use them properly.

### #19 jimblumberg

Reputation: 4887
• Posts: 15,264
• Joined: 25-December 09

## Re: Question about Fibonacci Sequence.

Posted 03 February 2013 - 10:00 AM

Use code tags when posting code! And you need to show some actual effort at solving your problem.

Jim

### #20 johnpaulbb02

Reputation: -1
• Posts: 11
• Joined: 15-January 13

## Re: Question about Fibonacci Sequence.

Posted 03 February 2013 - 10:22 AM

Let me try jim.