Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function i_to_a that converts a 32-bit integer into a string of ASCII digits. The function will receive as an argument a 32-bit

 

Write a function i_to_a that converts a 32-bit integer into a string of ASCII digits. The function will receive as an argument a 32-bit integer and it should return a string of digits contained in the integer. The output string should be an ASCIIZ string, i.e., ends with the null character (ASCII code 0). You may assume that the input will not be a negative number or a non-decimal value or too large a number. For example, i_to_a called with the argument 12345 will return the string "12345". Write a C program (ex2. c), where main () repeatedly reads an integer from the input, then calls i_to_a () with this integer as an argument. The function i_to_a () returns a string, which main prints using printf("%s ", . . .). The program should terminate when the integer read is 0. The name and type declaration of the function you create must be: void i_to_a (char *str, int num, int base) You may assume that the input string will not be longer than 20 digits. As you can guess, the base you will be using is 10. So the function will look like void i_to_a (char *str, int num, 10). You are free to eliminate the last argument in the function too, by hardcoding it to base 10. You cannot use itoa () function that is part of the C library. You must write your own function! For printing the value read you should use printf("%d ",...).

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

Computer Organization And Design The Hardware Software Interface

Authors: David A. Patterson, John L. Hennessy

4th Revised Edition

0123747503, 978-0123747501

More Books

Students also viewed these Programming questions

Question

What is the primary goal or objective in bulk welding?

Answered: 1 week ago