Random Num Gen Thing

Discussion in 'C Programming' started by Thiefcom, Jun 12, 2017.

  1. Thiefcom

    Thiefcom

    Joined:
    Jun 1, 2017
    Messages:
    55
    Likes Received:
    7
    Code (C):

    #include <iostream>
    using namespace std;

    int main()
    {
        const int a = 5;
        cout << "This program will get random nums" << a \
            << "Fibonacci nums" << endl;
         
            int num1 = 0, num2 = 1;
            char more = '\0';
            cout << num1 << " " << num2 << " ";
         
            do
            {
                for (int c = 0; c < a; ++c)
                {
                    cout << num1 + num2 << " ";
                 
                    int num2Temp = num2;
                    num2 = num1 + num2;
                    num1 = num2Temp;
                }
             
                cout << endl << "Do you want more numbers (y/n)";
                cin >> more;
            }while (more == 'y');
         
            cout "Goodbye" << endl;
            return 0;
    }
     
     
    Last edited by a moderator: Jun 14, 2017
    Thiefcom, Jun 12, 2017
    #1
    1. Advertisements

  2. Thiefcom

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    118
    Likes Received:
    14
    Location:
    Malaysia
    Please wrap your code with code tag. Thanks
     
    John Joe, Jun 13, 2017
    #2
    1. Advertisements

  3. Thiefcom

    Thiefcom

    Joined:
    Jun 1, 2017
    Messages:
    55
    Likes Received:
    7
    I don't know the wrap thing on this :(
     
    Thiefcom, Jun 14, 2017
    #3
  4. Thiefcom

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    118
    Likes Received:
    14
    Location:
    Malaysia
    John Joe, Jun 14, 2017
    #4
  5. Thiefcom

    Ian Administrator

    Joined:
    Nov 13, 2005
    Messages:
    35
    Likes Received:
    7
    I've updated this with code tags for you :).
     
    Ian, Jun 14, 2017
    #5
    John Joe likes this.
  6. Thiefcom

    Thiefcom

    Joined:
    Jun 1, 2017
    Messages:
    55
    Likes Received:
    7
    • thank you
     
    Thiefcom, Jun 15, 2017
    #6
  7. Thiefcom

    shaili shah

    Joined:
    Jul 15, 2019
    Messages:
    9
    Likes Received:
    0
    just wrap your code in tags with an option for the language.
     
    shaili shah, Sep 12, 2019 at 5:33 AM
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.