rendered paste body#include <stdio.h>#include <string.h>#include <stdlib.h>void division(int num, int num1, int array[], int count);int fibonacci(int input);int main(void){ /*Declare Variables*/ int fibNum1, fibNum2, fibNum3,x; int loop, loop1, loop2, temp; int error, winner, c; int FloatingPointArray[100], FloatingPointArray1[100]; char strInputString[100], result1[100], result2[100]; /*initalise variables*/ error = 0; /*take input*/ while (error != 1){ error = 0; printf("Number of floating digits required for the Golden section number?\n"); printf("Input: "); for (loop = 0; (c = getchar()) != EOF && c != '\n' && loop < 100; loop++){ if (c >= '0' && c <= '9'){ strInputString[loop] = c; } else { error = 1; } } if (error == 1){ printf("Output: Wrong Input, Please Re-enter\n"); error = 0; for (loop1 = 0; loop < 100; loop++){ strInputString[loop] = '0'; } } else { strInputString[loop+1] = '\n'; break; } } /*for loop*/ for (loop = 3; loop < 30; loop++){ winner = 0; /*get number 1*/ fibNum2 = fibonacci(loop); /*get number 2*/ fibNum1 = fibonacci(loop-1); temp = atoi(strInputString); /*number of floating points to match upto*/ /*do division*/ division(fibNum2, fibNum1, FloatingPointArray, temp+1);for (x = 0; x < temp; x++){ printf("Division1 %d", FloatingPointArray[x]);}printf("\n"); fibNum3 = fibonacci(loop+1); division(fibNum3, fibNum2, FloatingPointArray1, temp+1); for (x = 0; x < temp; x++){ } for (x = 1; x < temp+1; x++){ if (FloatingPointArray[x] == FloatingPointArray1[x]){ winner = 1; } else { winner = 0; break; } } if (winner == 1){ break; } } if (winner == 1){ printf("Output: Golden section number is:"); for (x = 0; x < temp+1; x++){ if (x == 1){ printf("."); } printf("%d", FloatingPointArray[x]); } printf(" (Fibonacci Rank: %d)",loop); } else { printf("Sorry but the value you entered resulted in a fibonacci number > 999, please try again with a lower input"); } printf("\n"); return 0;}void division(int intInputDividend, int intInputDivider, int FloatingPointArray[], int count){ double result, divider, dividend, remainder; /* standard variable initalisation - pretty self explanatory*/ int loop, count1; count1 = 0; dividend = intInputDividend; divider = intInputDivider; count = count + 1; while ((result = dividend - divider) != 0 && count != 0 ){ /*checks to see if the remainder isn't equal to zero, and it has not reached the length of required doubleing points*/ if (result < 0){ FloatingPointArray[count1] = 0; while (count != 0){ for (loop = 1; (result >= divider); loop++){ result = result - divider; /* calculates the actual remainder from each time round the loop*/ } FloatingPointArray[count1+1] = loop; count = count -1; ++count1; } return; } for (loop = 1; (result >= divider); loop++){ result = result - divider; /* calculates the actual remainder from each time round the loop*/ } remainder = result; FloatingPointArray[count1] = loop; /* stores the result into the array*/ count = count - 1; /* decrement count*/ ++count1; /* increment second counter*/ if (remainder == 0){ while (count != 0){ FloatingPointArray[count1] = 0 ; count = count -1; ++count1; } break; } if (remainder < 1){ dividend = remainder; } if (remainder > 100 && remainder < 1000){ dividend = remainder * 100; } if (remainder > 0 && remainder < 100){ dividend = remainder * 10; /*prepare the dividend for the next time around the loop*/ } if (remainder > 1000 && remainder < 10000){ dividend = remainder * 1000; } }}int fibonacci(int input){ int num1, num2, num0, fibLoop; num0 = 0; num1 = 1; num2 = 0; for (fibLoop = 1; fibLoop < input; fibLoop++) { num2 = num0 + num1; num0 = num1; num1 = num2; } return num2;}