Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write a C command line program, dec2base, as shown at the beginning of these assignment notes. It should handle each of the cases shown (wrong

Write a C command line program, dec2base, as shown at the beginning of these assignment notes. It should handle each of the cases shown (wrong number of arguments, one argument, two arguments) and render the result in the target base. 2. Your program must implement the following functions: void dec2base(int input,int base,char *str); void revStr(char *str, int length); Note that neither of these functions use the function return mechanism. Both functions use the pass by reference mechanism to write their results directly to the corresponding variables in the caller program. Function dec2base performs decimal to target base conversion as per Assignment 1 and writes the result to a string in reverse order. This makes it particular easy (simple) to implement with very few lines of code. Although the library has a string reverse function, you are to implement one yourself to gain familiarity in how C implements character strings. Note that since you determine the 7/8 length of the output string in dec2base, you can use this to simplify the writing of revStr. Also take note that unlike Java, strings are not immutable. You may not use any other functions in writing dec2base and revStr. 3. Run the following examples, making sure that your results are correct. Save these results to a file called dec2base.txt. ferrie@FastCat{Assignment 1}: dec2base 255 The Base-2 form of 255 is: 11111111 ferrie@FastCat{Assignment 1}: dec2base 65535 16 The Base-16 form of 65535 is: FFFF ferrie@FastCat{Debug}: dec2base 2147483647 The Base-2 form of 2147483647 is: 1111111111111111111111111111111 ferrie@FastCat{Debug}: dec2base 33975 5 The Base-5 form of 33975 is: 2041400 ferrie@FastCat{Debug}: dec2base 760976 9 The Base-9 form of 760976 is: 1378768 ferrie@FastCat{Debug}: dec2base 67878903 10 The Base-10 form of 67878903 is: 67878903 ferrie@FastCat{Debug}: dec2base 86 33 The Base-33 form of 86 is: 2K ferrie@FastCat{Debug}: dec2base 100100100 3 The Base-3 form of 100100100 is: 20222100121112010 ferrie@FastCat{Debug}: dec2base 2147483647 35 The Base-35 form of 2147483647 is: 15V22UM ferrie@FastCat{Debug}: dec2base 17 8 The Base-8 form of 17 is: 21

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students explore these related Databases questions