# C++ Fibonacci's Rabbits!!!!!

This is a discussion on C++ Fibonacci's Rabbits!!!!! within the C++ Programming forums, part of the General Programming Boards category; Hey, i wrote this program for fibonacci's sequence, it works, but im having a problem completing a modification of it, ...

1. ## C++ Fibonacci's Rabbits!!!!!

Hey, i wrote this program for fibonacci's sequence, it works, but im having a problem completing a modification of it, i want to write 2 programs , i have done the first , i need help on the second.

First problem: Write a program that accepts user input for the number of months, and computes the number of pairs of rabbits at that month. Use a for loop and within the for loop output the running total. (( ACCOMPLISHED ))

Second Problem: First problem: Write a program that accepts user input for the number of pairs of rabbits, and computes the minimum number of months it woud take to have that many pairs. Use a for loop and within the for loop output the running total.
(( NEED HELP ))

The C++ code is here:

Code:
```/*****************************************************************************************
**************************************ASSIGNMENT 2****************************************
******************************************************************************************
*                                                                                        *
*      Student Name:       Colin Raphael                                                 *
*      Student Number:     100727139                                                     *
*      Description:        This program uses fibonacci's sequence to determine the number*
*                          of pairs of rabbits by a given input of month.                *
*                                                                                        *
******************************************************************************************
******************************************************************************************
*****************************************************************************************/

#include <iostream>

using namespace std;

void main(void)
{
int f1=1,f0=0,f,x,i;                     //Declaring used variables
cout << "Enter the number of months: ";  //Prompts user for number of months
cin >> x;                                //Stores variable

for (i=1; i<=x; i++)                     //loop statement
{
f = f1 + f0;
cout <<"In month " << i << " there are " << f << " pair(s) of rabbits." << endl; // Outputting loop statment
break;                                                                          //stop loop
}

for (i=2; i<= x; i++)
{
f = f1 + f0;
f0 = f1;
f1 = f;
cout <<"In month " << i << " there are " << f << " pair(s) of rabbits." << endl;      // Outputting loop statement
}

cout <<"After " << x << " month(s) there are " << f << " pair(s) of rabbits."<<endl;  // conclusion
}```
>> I need somebody to modify it to satisfy problem 2 , please and thanks for your help

2. ok never mind i figured it out, this is what motivates me to keep programming , learning new stuff on the way!

thanks anyway if any of you were going to help!

3. Just one minot point, if you indent your code it does make it much easier to maintain, read and most importantly debug

4. Oh and

Code:
`void main ( void )`
should be

Code:
`int main ( void )`
As main must return an int value