Question: C function takes in string of digits and converts it to int and then returns factorial. program continues to prompt for user input until 0

C function takes in string of digits and converts it to intC function takes in string of digits and converts it to int and then returns factorial. program continues to prompt for user input until 0 is entered, then program ends. convert program to MIPS, must use syscall 8 to read inputs and syscall 1 to print. $a0 must be used to pass arguments and $v0 to return them

#include char input [22]; int a_to_i(chark str); / To read in a string of up to 20 digits plus newline and null 4 int factorial(int n); int main) int fact; int value; while(fact != 1){ printf("enter string:") fgets(input, 22, stdin); value a_to_i(input); // print f("%d ", value); fact factorial (value); printf("%d ", fact); 10 12 13 14 15 16 17 18 19 return 1; int a_to_i(char* str) int result 0; int i; for (i 0; input [i] . '; ++i) { != result = result * 10 + input [1] - .0'; - 24 25 26 27 28 29 30 31 32 return result int factorial(int n) if(n == 0){ return 1; if(n!=1){ 34 return n*factorial(n-1): 35 36 37

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!