add c and cpp

This commit is contained in:
Christoph J. Scherr 2025-08-05 13:52:02 +02:00
parent d9a0aa3b61
commit 1f5b67dd15
Signed by: PlexSheep
GPG key ID: 9EB784BB202BB7BB
3 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,4 @@
# Collection of FizzBuzz Programs
This repository contains various FizzBuzz implementations in various programming
languages.

15
src/fb.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
int main(int argc, char *argv[]) {
for (int i = 1; i <= 100; i++) {
if (i % 15 == 0) {
puts("FizzBuzz");
} else if (i % 3 == 0) {
puts("Fizz");
} else if (i % 5 == 0) {
puts("Buzz");
} else {
printf("%d\n", i);
}
}
return 0;
}

16
src/fb.cpp Normal file
View file

@ -0,0 +1,16 @@
#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 100; i++) {
if (i % 15 == 0) {
cout << "FizzBuzz" << endl;
} else if (i % 3 == 0) {
cout << "Fizz" << endl;
} else if (i % 5 == 0) {
cout << "Buzz" << endl;
} else {
cout << i << endl;
}
}
return 0;
}