For all of your programming needs and wants.


    A challenge "FIZZBUZZ"

    Share
    avatar
    ProgrammingLinguist
    Stranger
    Stranger

    Posts : 49
    Join date : 2010-01-06
    Location : LA

    A challenge "FIZZBUZZ"

    Post by ProgrammingLinguist on 1/6/2010, 10:08 pm

    This is a general coding exercise. It's very popular amongst programmers and requires basic coding knowledge. Since there isn't a "general coding" category I'm posting it in the C++ category because... i like C++ best Very Happy

    Problem:

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

    GZ
    Stranger
    Stranger

    Posts : 4
    Join date : 2009-10-28

    Re: A challenge "FIZZBUZZ"

    Post by GZ on 2/20/2010, 2:27 pm

    Code:
    #include <iostream>
    int main () {
       for ( char i = 0; i < 100; i++ ) {
       if ( i % 3 == 0 ) {
          cout << "Fizz\n";
       } else if ( i % 5 == 0 ) {
          cout << "Buzz\n";
       } else {
          cout << i << endl;
       }
    }

    return 0;
    }

      Current date/time is 10/22/2017, 1:14 pm