hba
  • hba
Anyone good with C#?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
hba
  • hba
I am trying to print the fibbancio sequence for n-number of terms. Need help --------- int a = 0; int b = 1; int c; Console.Write("please input number of series digits you want to go till:"); c = int.Parse(Console.ReadLine()); int x; for (int i = 1; i <= (c - 2); i++) { x = a + b; a = b; } Console.WriteLine("0,1,{0}", a);
DLS
  • DLS
do it like this.. for(int i=0;i
hba
  • hba
That's C++ :/

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

hba
  • hba
Moreover we know that the first two terms of the sequence are 0 and 1
DLS
  • DLS
man. int a=0; int b=1; for(int i=0;i
hba
  • hba
So we can keep them as same.
DLS
  • DLS
remove the cout thing use the Console.Write thing instead.
hba
  • hba
Therfore,We are counting it upto n-2 terms.
DLS
  • DLS
both are OOP based,same code.
DLS
  • DLS
n-2? no?
hba
  • hba
Yes i am right.
hba
  • hba
Because i am putting two terms already which i know can never change which are 0 and 1. Therefore subtracting these terms from n it comes as n-2
DLS
  • DLS
int a=0; int b=1; for(int i=0;c<=n;i++) { a=b; b=c; c=a+b; Console.Write(c); } ------------------------------------------------------------- Please input number of series digits you want to go till ------------------------------------------------------------- 10 ------------------------------------------------------------- 0 1 1 2 3 5 8
DLS
  • DLS
where are you getting confused?
hba
  • hba
You will never get my point. Nevermind.
hba
  • hba
Confused? I am not confused at all.
hba
  • hba
I just want to know how to get the printing done.
DLS
  • DLS
Shouldn't you mention that in your question? -_-
hba
  • hba
Ah! That was understood. My Idea is right. But i am not able to print it.
DLS
  • DLS
oh well. print the first 2 values before the loop? then display C
hba
  • hba
like, Its gonna be like 0,1,1 But then that 1 which is c has to keep changing but it just appears as 0,1,1 < That's it. It should be like 0,1,1,2,3,5,8,13...
anonymous
  • anonymous
you never reassign the value x = a + b to b, so your program keep calculating a + b while they both stay 1, and you want to print the number as you calculated it, because you don't have access to the calculated numbers after the loop. ie: int a = 0; int b = 1; int c; Console.Write("please input number of series digits you want to go till:"); c = int.Parse(Console.ReadLine()); int x; Console.Write("0 1 "); // Writing the first two terms for (int i = 1; i <= (c - 2); i++) { x = a + b; a = b; b = x; Console.Write("{0} ", x); }
anonymous
  • anonymous
ahummmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
hba
  • hba
@Meepi I tried to dry run it and got my error and did exactly the same as you did.Thanks anyways.
anonymous
  • anonymous
Are you sure that you rebuild the thing? I've tested it and it works for me :/

Looking for something else?

Not the answer you are looking for? Search for more explanations.