💾 Archived View for sdf.org › aiden › src › fizzbuzz.c captured on 2024-07-08 at 23:41:59.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

#include <stdio.h>

int
main()
{
  int num, f, b, i;

  num = 1;
  while (1) {
    f = 0;
    b = 0;
    
    for(i = 1;i < 200000; ++i); //delay so that the screen doesn't get flooded.

    if (num % 3 == 0) ++f;
    if (num % 5 == 0) ++b;

    if((f + b) == 2) printf("fizzbuzz ");
    if(f == 1) printf("fizz ");
    if(b == 1) printf("buzz ");
    if((f + b) == 0) printf("%d ", num);
    
    ++num;
  }
  
  return 0;
}