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

Solve using C++ Drill 1. Start a program called Test output.cpp. Declare an inte

ID: 3586795 • Letter: S

Question

Solve using C++

Drill 1. Start a program called Test output.cpp. Declare an integer birth ,year and assign it the year you were born. Output your birth year in decimal, hexadecimal, and octal form. 3. Label cach value with the name of the base used. 4. Did you line up your output in columns using the tab character? If not, do it. 5. Now output your age. 6. Was there a problem? What happened? Fix your output to decimal. Go back to 2 and cause your output to show the base for each output 8. Tiry reading as octal, hexadecimal, ctc. Run this code with the input 1234 1234 1234 1234 Explain the results. defaultfloat, then fixed, then scientific forms. Which output form pre- 9. Write some code to print the number 1234567.89 three times, first using sents the user with the most accurate representation? Explain why. 10. Make a simple table including last name, first name, telephone number. and email address for yourself and at least five of your friends. Experi ment with different field widths until you are satisfied that the table is well presented.

Explanation / Answer


Decimal to Hexadecimal:
#include<iostream>
using namespace std;
int main()
{
long int birth_year = 1997;
long int quotient;
char hexaDec[100];
int iObj=1, jObj, temp;
quotient=birth_year;
while(quotient!=0)
{
temp=quotient%16;
if(temp<10)
{
temp=temp+48;
}
else
{
temp=temp+55;
}
hexaDec[iObj++]=temp;
quotient=quotient/16;
}
cout<<"Hexadecimal value of is : ";
for(jObj=iObj-1; jObj>0; jObj--)
{
cout<<hexaDec[jObj];
}
}
output:
Hexadecimal value of is: 7CD
Decimal to binary:

#include<iostream>
using namespace std;
int main()
{
int birth_year = 4;
long remainder,i,sum=0;

do
{
remainder=birth_year%2;
sum=sum + (i*remainder);
birth_year=birth_year/2;
i=i*10;
}while(birth_year>0);
  
cout<<"The Decimal number in Binary:"<<sum<<endl;
cout<<endl;
return 0;

}
output:
The Decimal number in Binary:100

Decimal to Octal:
#include <iostream>
using namespace std;
int main()
{
int birth_year = 78;
int remVal, iObj = 1, octNum = 0;
while (birth_year != 0)
{
remVal = birth_year % 8;
birth_year /= 8;
octNum += remVal * iObj;
iObj *= 10;
}
cout << octNum;

return 0;
}
output:'
116