Access over 20 million homework & study documents

With out using printf in c how do you do theseint printC(int c);

Content type
User Generated
Rating
Showing Page:
1/3
With out using printf in c how do you do these
int printC(int c); // Outputs the character c if it is printable
int printS(const char *s); // Outputs the string s
int printI(int i); // Outputs the integer i as a base -10
string
int printX(int i); // Outputs the integer i as a hexadecimal
string
int printF(double x, int n); // Format: fff.ffff
Outputs x as a fixed point string with n digits to the right
of the decimal point. Value should be properly rounded. If
n < 0, do not print the decimal point (otherwise the same
as n = 0).
int printE(double x, int n); // Format: f.fffea (x = f.fff *
10^a)
Outputs x in exponential notation with exactly one non -
zero digit to the left of the decimal point (unless x = 0)
and n digits to the right, a lowercase e, and the
exponent. If n < 0, do not print the decimal point
(otherwise same as n = 0).
Solution

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
Answer:
Here is how we can write it without printf : -
int printS(const char *s)
{
if (*s == \'\\0\')
return;
prnt (s + 1);
putchar (*s);
}
int printC(int c)
{
putchar (c);
}
int printX(int i)
{
if(i < 10) putchar((char)i);
else if (i == 10) putchar(\'A\');
else if (i == 11)
putchar(\'B\');
else if (i == 12)
putchar(\'C\');
else if (i == 13)
putchar(\'D\');

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Great! 10/10 would recommend using Studypool to help you study.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4