Random Num Gen Thing

Joined
Jun 1, 2017
Messages
55
Reaction score
7
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:

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. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top