Skip to content

Instantly share code, notes, and snippets.

@CarterA
Created December 21, 2011 01:00
Show Gist options
  • Save CarterA/1504046 to your computer and use it in GitHub Desktop.
Save CarterA/1504046 to your computer and use it in GitHub Desktop.
FizzBuzz
//
// main.c
// FizzBuzz
//
// Created by Carter Allen on 12/20/11.
// Copyright (c) 2011 Opt-6 Products, LLC. All rights reserved.
//
#include <stdio.h>
int main () {
for (int i = 1; printf(((i % 3 != 0 && i % 5 != 0) ? "%s%s%d%s" : "%s%s%n%s"), ((i % 3 == 0) ? "Fizz" : ""), ((i % 5 == 0) ? "Buzz" : ""), ((i % 3 != 0 && i % 5 != 0) ? i : '\0'), ((i == 100) ? "\n" : ", ")), i <= 100; i++) {}
return 0;
}
@zfisher
Copy link

zfisher commented Dec 21, 2011

for (int index = 1; printf(((index % 3 != 0 && index % 5 != 0) ? "%s%s%d%s" : "%s%s%n%s"), ((index % 3 == 0) ? "Fizz" : ""), ((index % 5 == 0) ? "Buzz" : ""), ((index % 3 != 0 && index % 5 != 0) ? index : '\0'), ((index == 100) ? "\n" : ", ")), index <= 100; index++) {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment