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
Showing Page:
2/3
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\');
Showing Page:
3/3
else if (i == 14)
putchar(\'E\');
else if (i == 15)
putchar(\'F\');

### Unformatted Attachment Preview

Name: Description: ...
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4