Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

hba

Anyone good with C#?

  • one year ago
  • one year ago

  • This Question is Closed
  1. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    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);

    • one year ago
  2. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    do it like this.. for(int i=0;i<n;i++) { a=b; b=c; c=a+b; cout<<c; } will do.

    • one year ago
  3. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    That's C++ :/

    • one year ago
  4. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    Moreover we know that the first two terms of the sequence are 0 and 1

    • one year ago
  5. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    man. int a=0; int b=1; for(int i=0;i<n;i++) { a=b; b=c; c=a+b; cout<<c; Console.Write(c); }

    • one year ago
  6. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    So we can keep them as same.

    • one year ago
  7. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    remove the cout thing use the Console.Write thing instead.

    • one year ago
  8. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    Therfore,We are counting it upto n-2 terms.

    • one year ago
  9. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    both are OOP based,same code.

    • one year ago
  10. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    n-2? no?

    • one year ago
  11. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes i am right.

    • one year ago
  12. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    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

    • one year ago
  13. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    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

    • one year ago
  14. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    where are you getting confused?

    • one year ago
  15. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    You will never get my point. Nevermind.

    • one year ago
  16. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    Confused? I am not confused at all.

    • one year ago
  17. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    I just want to know how to get the printing done.

    • one year ago
  18. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    Shouldn't you mention that in your question? -_-

    • one year ago
  19. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    Ah! That was understood. My Idea is right. But i am not able to print it.

    • one year ago
  20. DLS
    Best Response
    You've already chosen the best response.
    Medals 1

    oh well. print the first 2 values before the loop? then display C

    • one year ago
  21. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    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...

    • one year ago
  22. Meepi
    Best Response
    You've already chosen the best response.
    Medals 0

    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); }

    • one year ago
  23. khurramshahzad
    Best Response
    You've already chosen the best response.
    Medals 0

    ahummmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

    • one year ago
  24. hba
    Best Response
    You've already chosen the best response.
    Medals 0

    @Meepi I tried to dry run it and got my error and did exactly the same as you did.Thanks anyways.

    • one year ago
  25. Meepi
    Best Response
    You've already chosen the best response.
    Medals 0

    Are you sure that you rebuild the thing? I've tested it and it works for me :/

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.