Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use C for two functions: print integer(int n, int radix, char* prefix) with return type : void Print the number n to the console (stdout)
use C for two functions:
print integer(int n, int radix, char* prefix) with return type: void
-
Print the number n to the console (stdout) in the specified number base (radix), with the prefix immediately before the first digit. radix may be any integer between 2 and 36 (inclusive). n may be any int. For values of radix above 10, use lowercase letters to represent the digits following 9. print_integer() should not print a newline ('n' or 'r'). Examples:
- print integer(768336, 10, "") should print 768336 because the number seven-hundred sixty-eight thousand three-hundred thirty-six would be written as 768336 in base 10 (decimal).
- print integer(-768336, 10, "") should print -768336.
- print integer(-768336, 10, "$") should print -$768336. Notice that the prefix ("$") comes after the "-" and before the first digit.
- print integer(768336, 16, "") should print bb950 because the number seven-hundred sixty-eight thousand three-hundred thirty-six would be written as bb950 in base 16 (hexadecimal).
- print integer(768336, 16, "0x") should print 0xbb950. The 0x prefix is added only because it is passed as an argument to print_integer().
- print integer(-768336, 16, "0x") should print -0xbb950.
- print integer(-768336, 2, "0b") should print -0b10111011100101010000.
- print integer(768, 10, ""); print integer(-336, 10, "") should print "768336".
******Use fputc and stdout instead of printf
******Can't use arrays to store strings
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started