Speed up development with full-stack environments for every branch.

Learn More

Olly's FizzBuzz [C++]

Forked from Hello World C++ Example.

3 Runs 20 Views 0 Copies
Saved

Saved

SpecialMango 1

SpecialMango
published 18 days ago

    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    
    	int Multiple1 = 0;
    	int Multiple2 = 0;
    	int MaxNumber = 0;
    
    	char again = 'Y';
    
    	while (again == 'y' || again == 'Y')
    	{
    
    		cout << "Olly's WizzBuzz" << endl;
    		cout << "Input Your First Multiple: " << endl;
    		cin >> Multiple1;
    		cout << "Your First Multiple Is: " << Multiple1 << endl;
    
    		cout << "Input Your Second Multiple: " << endl;
    		cin >> Multiple2;
    		cout << "Your Second Multiple Is: " << Multiple2 << endl;
    
    		cout << "Input Your Maximum Number: " << endl;
    		cin >> MaxNumber;
    		cout << "Your Maximum Number is: " << MaxNumber << endl;
    
    		for (int i = 1; i <= MaxNumber; i++)
    		{
    			if (i % Multiple1 == 0 && i % Multiple2 == 0)
    				cout << "FizzBuzz" << endl;
    			else
    				if (i % Multiple1 == 0)
    					cout << "Fizz" << endl;
    				else
    					if (i % Multiple2 == 0)
    						cout << "Buzz" << endl;
    					else cout << i << endl;
    
    
    		}
    
    		{
    			cout << "Restart? (y/n) ";
    			cin >> again;
    
    
    
    		}
    		
    	}
    
    	cin.get();
    	cout << "Thanks for playing" << endl;
    	return 0;
    
    }
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).