You are on page 1of 2

#include <stdio.

h>
int Fibonacci(int value)
{
if (value == 1 || value == 2)
{
return 1;
}
return Fibonacci(value - 2) + Fibonacci(value - 1);
}
int Factorial(int value)
{
if (value < 2)
{
return 1;
}
else
{
return value * Factorial(value - 1);
}
}
void HereIsAFunctionWithAString(char string[], int number)
{
int count = 0;
while (string[count] != '\0')
{
string[count] += number;
count += 1;
}
}
void ThisIsAHelperFunction(char t, int v)
{
int i;
for (i = 0; i < v; i++)
printf("%c", t);
}
int Function_P(int i, int j, int k)
{
return (j * k) + i;
}
int Function_Q(int x)
{
return Function_P(x - 1, x, x + 1);
}
int main(void)
{
printf("%d\n\n", Function_P(3, 4, 5));
printf("%d\n\n", Function_P(3, 4, 6));
printf("%d\n\n", Function_P(3, 4, 7));
printf("%d\n\n", Function_P(3, 4, 8));
printf("@@ %d @@\n\n", Function_Q(8));
ThisIsAHelperFunction('Q', 39);
printf("\n\n");
char string[] = "NORTH CAROLINA AVENUE\0";
printf("%s\n", string);
HereIsAFunctionWithAString(string, 32);
printf("%s", string);

printf("\n\n");
int i;
for (i = 0; i < 5; i++)
{
printf("%d! = %d\n", i, Factorial(i));
}
printf("\n");
for (i = 1; i < 20; ++i)
{
printf("F(%d) = %d\n", i, Fibonacci(i));
}
printf("\n\n");
return 0;
}

You might also like