Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

With out using printf in c how do you do these int printC(int c); // Outputs the

ID: 3817158 • Letter: W

Question

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).

Explanation / Answer

Answer:

Here is how we can write it without printf : -

int printS(const char *s)

{

if (*s == '')

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');

else if (i == 14)

putchar('E');

else if (i == 15)

putchar('F');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote