Skip to content

Instantly share code, notes, and snippets.

@willeccles
Last active February 24, 2023 01:52
Show Gist options
  • Save willeccles/cbf245f180bb0f1ecee122a8a5c25ed1 to your computer and use it in GitHub Desktop.
Save willeccles/cbf245f180bb0f1ecee122a8a5c25ed1 to your computer and use it in GitHub Desktop.
A C program which is also a valid bash script, and vice versa.
#include <stdio.h>
#define $x ,x
#define $i ,i
#define eval int
#define read scanf
#define $scanfpat "%d", &
#define $(x) ,(x)
#define $open (
#define $close )
#define do {
#define done }
#define then {
#define fi }
#define else } else {
main() {
eval i=0;
eval x=7;
read $open $scanfpat x $close;
for (( i = 0 $close; i < 5; $open i++ ))
do
printf $open "%d\n" $((x+i)) $close;
done
if (( x % 2 ))
then
printf $open "%d is odd\n" $x $close;
fi
for (( i = 1 $close; i <= 100; $open i++ ))
do
if (( i % 3 ))
then
if (( i % 5 ))
then
printf $open "%d\n" $i $close;
else
printf $open "buzz\n" $close;
fi
else
if (( i % 5 ))
then
printf $open "fizz\n" $close;
else
printf $open "fizzbuzz\n" $close;
fi
fi
done
return 0;
}
#if 0
main
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment