Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedC 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

Students also viewed these Databases questions

Question

=+gets managed true? Give your arguments.

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago