AI Chat
AI Chat is an AI chatbot that writes text. You can use it to write stories, messages, or programming code. You
can use the AI chatbot as a virtual tutor in almost any subject.
Certainly! Below is an example of a simple FizzBuzz program written in C. FizzBuzz is a common programming task often used in job interviews. The task is to print the numbers from 1 to 100, but for multiples of 3 print "Fizz" instead of the number, for multiples of 5 print "Buzz", and for multiples of both 3 and 5 print "FizzBuzz".
```c
#include <stdio.h>
int main() {
for (int i = 1; i <= 100; ++i) {
if (i % 3 == 0 && i % 5 == 0) {
printf("FizzBuzz\n");
} else if (i % 3 == 0) {
printf("Fizz\n");
} else if (i % 5 == 0) {
printf("Buzz\n");
} else {
printf("%d\n", i);
}
}
return 0;
}
```
To compile and execute this program, save it to a file with a `.c` extension (for example, `fizzbuzz.c`), then run the following commands in your terminal:
```sh
gcc -o fizzbuzz fizzbuzz.c
./fizzbuzz
```
This will compile the program using GCC (GNU Compiler Collection) and create an executable named `fizzbuzz`, which you can then run to see the FizzBuzz output.
Make sure you have a C compiler installed (like GCC or Clang) on your system to compile and run C programs.