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

FizzBuzz

Name: VIPPER 2011-05-15 3:49

Write a program that prints the integers 1 - 100, but for every multiple of 3, print "Fizz" instead of the number, for every multiple of 5 print "Buzz", and for every multiple of both 3 and 5, print "FizzBuzz".


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
        for (int i = 1; i <= 100; i++) {
                if (i % 3 == 0 && i % 5 == 0)
                        puts("FizzBuzz");
                else if (i % 3 == 0)
                        puts("Fizz");
                else if (i % 5 == 0)
                        puts("Buzz");
                else
                        printf("%d\n", i);
        }
        return EXIT_SUCCESS;
}

Name: Anonymous 2011-05-15 4:54

...Why?

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