Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

90% of /prog/ can't write FizzBuzz

Name: The antagonist 2008-04-25 12:38

Prove me wrong

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Name: Anonymous 2008-04-29 9:58

// Fizz Buzz

#include <iostream>
using namespace std;

int nums[101];

int main ()
{

for (int i = 1; i < 101; i ++)
{

if ( (i % 3) == 0)
    cout << "Fizz \n";

else if ( (i % 5) == 0)
    cout << "Buzz \n";

else if ( ((i % 3) == 0) && ((i % 5) == 0))
    cout << "FizzBuzz \n";

else
    cout << i << "\n";

}

return 0;

}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List