(27)-slwoolupo x(4 COP2270: Chapters 8,9 a xM Recibidos m/mail/ju/1/Winbox/15cf6
ID: 3855463 • Letter: #
Question
(27)-slwoolupo x(4 COP2270: Chapters 8,9 a xM Recibidos m/mail/ju/1/Winbox/15cf6cf5b61fdf 427projector- 1 Open with D) PE 09 01 (Printing Integers) Write a program that summarizes the integer conversion specifiers discussed in class (d, i, o, u, x or X). The program should generate a neatly formated table that lists each conversion specifier, with a brief and accurate description of its operation, and provide an example integer conversion in a printf statement Printing Integers: -55 signed integers-125 signed integers octal integers unsigned integers %i 73 127 tx hexdecimal integers Stta 2) PE 09 02 (Decimal, Octal, and Hexadecimal Integers) Write a program that counts to 32 using decimal, octal, and hexadecimal integers. You output should be neatly formatted as illustrated below. Use the correct conversion specifier and flags to produce the leading zeros. DEC 001 000 001002 002 001 0 003 004 017 018 019 01 025 032 01 002 003 003 004 023 004 (data removed intentionally) 027 024 030 031 026 03301C 027 034 01D 02803501E 029 036 01F 031 03602b 032 037 02E 040 030 Page 23 MacBook Air o,, 0 3 4 8Explanation / Answer
1.
#include<stdio.h>
int main() {
int i;
char *s = "signed";
i = -55;
printf("Printing Integers: ");
printf("%%d%13s integers%*d ",s, 8, i);
i = -125;
printf("%%i%13s integers%*i ",s, 8, i);
i = 59;
s = "octal";
printf("%%o%13s integers%*o ",s, 8, i);
i = 127;
s = "unsigned";
printf("%%u%13s integers%*u ",s, 8, i);
i = 24570;
s = "hexadecimal";
printf("%%x%13s integers%*x ",s, 8, i);
}
2.
#include<stdio.h>
int main() {
int i;
printf("DEC OCT HEX ");
for (i = 0; i<=32; i++)
printf("%03d %03o %03x ",i,i,i);
}
Let me know if this helped. I shall be glad to help you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.