Im not really in the major of c++ or I.T i need your help
The Fibonacci Sequence it must lead the sequence 0,1,1,2,3,5,8,13,21....
A program that will generate a Fibonacci of a specified length given the first 2 numbers in the sequence. First input an integer N that specifies the length of the sequence that will be generated(including the first two). This shall be restricted from 2 to 100.
This is then followed by two integers A and B (not necessarily on the same line), first and second numbers in the sequence.
Both A and B are from 0 to 100,inclusive. B should be greater than A.
THe program shall validate all input values that displays the ff. "invalid length" "First number out bounds" "Second number out bounds" "second number should be greater than the first" and require re-entry of the 3 integer input..thanks guys! :D

Who gives you this homework ?
I better email him.

Who gives you this homework ?
I better email him.

My Professor did..it was a homework..this is what i did..but still its wrong.
#include<iostream.h>
int main()
{
cout<<"\n this is a Fiboccani-Type Sequence";
int a,b,c,sum;
do{
system('cls');
cout<<"\n Enter the length:";
cin>>c;
cout<<"\n Enter the first number:";
cin>>a;
cout<<"\n Enter the second number:";
cin>>b;
if (a<100)
cout<<"\n the first number out bounds";
if (b<100)
cout<<"\n the second number out bounds";
if (sum<100)
cout<<"\n Invalid length";

}while (a>b);
sum= a+b;
cout<<"\n the length is:"<<sum;

return 0;
}

OK, that's better. I think you need to take the time to break the problem down into smaller parts.

Figure out how to do the first part first:

...
First input an integer N that specifies the length of the sequence that will be generated(including the first two). This shall be restricted from 2 to 100.
...
THe program shall validate all input values that displays the ff. "invalid length"
...

There will be several loops in your program. This is the first. Figure out how to write this, then post back.

OK, that's better. I think you need to take the time to break the problem down into smaller parts.

Figure out how to do the first part first:

There will be several loops in your program. This is the first. Figure out how to write this, then post back.

I don't have a program..our class is just once a week. im trying to find a program in the net,but it all failed...do you know any?

If you don't have a program then what is this?

``````#include<iostream.h>
int main()
{
cout<<"\n this is a Fiboccani-Type Sequence";
int a,b,c,sum;
do{
system('cls');
cout<<"\n Enter the length:";
cin>>c;
cout<<"\n Enter the first number:";
cin>>a;
cout<<"\n Enter the second number:";
cin>>b;
if (a<100)
cout<<"\n the first number out bounds";
if (b<100)
cout<<"\n the second number out bounds";
if (sum<100)
cout<<"\n Invalid length";

}while (a>b);
sum= a+b;
cout<<"\n the length is:"<<sum;

return 0;
}``````

Do you know why this one failed? It's not even close. It doesn't generate or display anything relevant. Where is your Fibonacci equation? Where is your list of generated Fib values? Answer, they're non-existant.

Do you know what a Fibonacci sequence is and how to generate one?

It doesn't matter if your class only meets once per week. Assignments have requirements and those requirements must be met. That's the whole point of homework. I could write this program for you pretty easily. But what good would that do you? An easy 'A' and no education, that's what it would do for you. It's completely contrary to the point of DaniWeb...

You know your basic program structure. Get that in place, then start building your loop(s). I presume that's the whole point of this assignment, to teach you how to build loops. You'll need a loop for your length, one (possibly 2) for the starter numbers and one each for the generation and display (these could potentially be combined).

I did that in school..and we must submit that next meeting which is 5 days from today..i tried to download some c++ progams but the microsoft visual 2010 confuses me..it says invalid code.the microsoft visual 6.0 c++ has no seeders. do you have any sites where i can have the program so i could learn how to do it???

Don't think I don't see what you are doing. Do your own homework.

You have 5 days, try to get the first part working, like I mentioned above. Here is a reference for control structures, it will tell you how to build a loop.

hey thanks..ill get back to this thread after I studied about the loops..appreciate it a lot. :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.