Created
September 10, 2014 18:52
-
-
Save jadudm/533e93bc649f29d84412 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A short FizzBuzz implementation, primarily for | |
demonstration of some of the features of C. | |
To compile this program, at the terminal, type: | |
gcc fizzbuzz.c | |
which will give you the executable "a.out". | |
To run it, type: | |
./a.out | |
You may want to CTRL-K to clear your terminal first, and | |
it is possible you may also want to increase the scrollback buffer. | |
Also, turn on AUTOSAVE. :) | |
*/ | |
/* Includes */ | |
#include <stdio.h> | |
/* Main */ | |
/* main() must return an int. */ | |
int main () | |
{ | |
int i; | |
for (i = 0 ; i < 1024 ; i += 1 ) | |
{ | |
/* C++ | |
cout << i << eol?; | |
Python | |
print i | |
*/ | |
if ((i % 3 == 0) && (i % 5 == 0)) { | |
printf("FizzBuzz\n"); | |
} else if (i % 5 == 0) { | |
printf("Buzz\n"); | |
} else if (i % 3 == 0) { | |
printf ("Fizz\n"); | |
} else { | |
printf("%d\n", i); | |
} | |
} | |
/* Return 0; everything is JUST FINE. */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment