#include "stdio.h"
// The function that contains most of the main program code
void main_program()
{
int fib_1 = 0;
int fib_2 = 1;
int fib_max = 0;
printf("Enter the amount of fibonacci numbers you want: ");
scanf("%d", &fib_max);
for (int counter = 0;counter < fib_max;counter++)
{
printf("%d", fib_1);
printf(", ");
int holder = fib_1 + fib_2;
fib_1 = fib_2;
fib_2 = holder;
}
printf("\n");
go_again();
}
void go_again()
{
char user_answer;
char c;
while ((c = getchar()) != '\n' && c != EOF) { }
printf("Would you like to run the program again [y or n]: ");
scanf("%c", &user_answer);
if (user_answer == 'y')
{
printf("\n");
main_program();
}
else if (user_answer == 'n')
{
printf("Thanks for using the program\n");
return;
}
else
{
go_again();
}
}
int main()
{
main_program();
return 0;
}