Question: #include #include #include int calculateFactorial(int n); void getBinary(int arr[], int number, int numOfBits); void printArray(int arr[], int numberOfElements); int main(void) { int numOfBits = 8

#include  #include  #include  int calculateFactorial(int n); void getBinary(int arr[], int number, int numOfBits); void printArray(int arr[], int numberOfElements); int main(void) { int numOfBits = 8 * sizeof(int); int arr[numOfBits]; //int upperBound = pow(2, numOfBits - 1) - 1; //int lowerBound = - pow(2, numOfBits - 1); //Declare integer n to hold the decimal integer int n = 0; int factorialResult = 0; puts("Enter integers and convert it to binary."); puts("Non-numeric input terminates program."); //Continually taking input and converting it to binary while (scanf("%d", &n) == 1) {//if successfully read in ONE decimal integer //Initialize the array to all 0s for(int i = 0; i < numOfBits; i ++){ arr[i] = 0; } factorialResult = calculateFactorial(n); getBinary(arr, factorialResult, numOfBits); //Output binary: printf("Factorial(%d) = %d,\t", n, factorialResult); printf("Binary: "); printArray(arr, numOfBits); } return EXIT_SUCCESS; } /* calculateFactorial of argument number n Factorial of a positive integer n is defined as the product of all positive integers less than or equal to n. Factorial zero is defined as equal to 1. */ int calculateFactorial(int n){ int result = 0; // what should be the initial value? return result; } /*getBinary - get the binary representation of number into the array arr. Arguments: arr - the integer array to hold the binary representation number - the integer to get binary from numOfBits - the size of the arr and the number of bits for the binary Algorithm requirement: make use of bitwise shifting and masking to get the bit values for the number */ void getBinary(int arr[], int number, int numOfBits){ } /* printArray: print numberOfElements in the argument integer array */ void printArray(int arr[], int numberOfElements){ int i = 0; for(; i < numberOfElements; i ++){ printf("%d", arr[i]); } puts("");//new line }
 Calculate fatorial of user-entered integer. Display the result in both decimal and binary format.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!