- Your name - Your e-mail address - Your High School - Home town - Current colle
ID: 3629209 • Letter: #
Question
- Your name
- Your e-mail address
- Your High School
- Home town
- Current college
- Current year in school
- Your age in decimal
- Your age in octal
- Your age in hexadecimal
on eight separate lines. Include a label before each piece of
information you print. Treat your age as a stored numeric
piece of data by placing it in a variable. Use conversion
specifiers to produce the various bases for the one value
in that variable.
Do not read any inputs, just produce the output.
Ex:
Name: John Doe
E-mail: jdoe@mymail.com
High School: Central Minnesota High
Home town: Lake Big
Current College: College
Current year in school: High school senior
Age: 17
Age in octal: 21
Age in hexadecimal: 11
Explanation / Answer
to print the labels you need to use the printf function printf ("Name: John Doe "); \ is new line or you can put the variables "Answers to questions" in a variables "string" string name (john don); printf ("Name: %s ", name); for the age you have to put it in an integer int age = 17 printf ("Age: %i ", age); to octal int cnt = 0; int TOC[100]; while (age != 0) { /* we save all reminders in the array */ TOC[cnt++] = age % 8; age = age / 8; } int tmp; for (cnt = cnt - 1; cnt >= 0; cnt--) { tmp += TOC[cnt] * pow(10, cnt); } after that print tmp to hex int quotient, ctr; for (ctr = 1; ctrRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.