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

how to scale and shift the number produced in C programming text..??? The user w

ID: 3646333 • Letter: H

Question

how to scale and shift the number produced in C programming text..???


The user will provide as input a power of ten and you will generate a second value that is between 0 and the power designated by the user minus 1. This value will be the remainder (those digits to the right of the decimal point) for the first number generated.

HOW CAN WE SCALE AND SHIFT THE NUMBER PRODUCED??

Explanation / Answer

#include //#include // Function declarations // typedef __w64 unsigned int size_t size_t strlen(const char *); char *strrev(char *); char *itoa(int, char *, int); int main() { int num = 123; char buf[5]; itoa(num, buf, 10); printf("%s ", buf); return 0; } size_t strlen(const char *string) { const char *s; s = string; while (*s) s++; return s - string; } char *strrev(char *str) { char *p1, *p2; if (!str || !*str) return str; for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) { *p1 ^= *p2; *p2 ^= *p1; *p1 ^= *p2; } return str; } char *itoa(int n, char *s, int b) { static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; int i=0, sign; if ((sign = n) < 0) n = -n; do { s[i++] = digits[n % b]; } while ((n /= b) > 0); if (sign < 0) s[i++] = '-'; s[i] = ''; return strrev(s); }