I have C Programming question that I do not know how to do i

I have C++ Programming question that I do not know how to do it, can you teach me how to do it?

-Explain how to convert a base 2 fraction to a base 8 or 16 fraction.

            Convert the three base 2 numbers: 1.1, 1.11 and 1.111 to base 8 and 16, show the manual conversion.
     ( DO NOT \'Mindlessly\' COPY AND PASTE ANY ANSWERS FROM THE INTERNET )
    Your document will be run against \'Turn It In\'

Part II - Please create a C++ programming in one file (Not a C Programming), also use iostream and build easier programming.

     Write a C++ OOP program that accepts as inputs a base 10 integer number.

     Convert that number into a base 2, 8 and 16 number.

Solution

Solution for Problem(c++):-

Program :-

#include<iostream>
using namespace std;
int main()
{
int num[100],i,j=1,sum=0,rem,number,octol,hexa[100],temp,k,l;
cout<<\"Enter 10 integer numbers :\"<<endl;
for(i=0;i<10;i++)
{
cin>>num[i];
}
for(i=0;i<10;i++)
{
sum=0;
j=1;
number=num[i];
do
{
rem=number%2;
sum=sum + (j*rem);
number=number/2;
j=j*10;
}while(number>0);
  
octol=0;
j=1;
number=num[i];
while (number != 0)
{
rem =number % 8;
number /= 8;
octol += rem * j;
j *= 10;
}
  
k=1;
number=num[i];
while(number!=0)
{
temp=number%16;
// to convert integer into character
if(temp<10)
{
temp=temp+48;
}
else
{
temp=temp+55;
}
hexa[k++]=temp;
number=number/16;
}
cout<<\"The Binary(Base 2) value for \"<<num[i]<<\" = \"<<sum<<endl;
cout<<\"The Octol(Base 8) value for \"<<num[i]<<\" = \"<<octol<<endl;
cout<<\"The Hexadecimal(Base 16)value for \"<<num[i]<<\" = \";
for(l=k-1;l>0;l--)
{
cout<<(char)hexa[l];
}
cout<<endl<<endl;
}
return 0;
}

Output :-

Enter 10 integer numbers :
8 9 10 11 12 13 14 15 45 50
The Binary(Base 2) value for 8 = 1000
The Octol(Base 8) value for 8 = 10
The Hexadecimal(Base 16)value for 8 = 8

The Binary(Base 2) value for 9 = 1001
The Octol(Base 8) value for 9 = 11
The Hexadecimal(Base 16)value for 9 = 9

The Binary(Base 2) value for 10 = 1010
The Octol(Base 8) value for 10 = 12
The Hexadecimal(Base 16)value for 10 = A

The Binary(Base 2) value for 11 = 1011
The Octol(Base 8) value for 11 = 13
The Hexadecimal(Base 16)value for 11 = B

The Binary(Base 2) value for 12 = 1100
The Octol(Base 8) value for 12 = 14
The Hexadecimal(Base 16)value for 12 = C

The Binary(Base 2) value for 13 = 1101
The Octol(Base 8) value for 13 = 15
The Hexadecimal(Base 16)value for 13 = D

The Binary(Base 2) value for 14 = 1110
The Octol(Base 8) value for 14 = 16
The Hexadecimal(Base 16)value for 14 = E

The Binary(Base 2) value for 15 = 1111
The Octol(Base 8) value for 15 = 17
The Hexadecimal(Base 16)value for 15 = F

The Binary(Base 2) value for 45 = 101101
The Octol(Base 8) value for 45 = 55
The Hexadecimal(Base 16)value for 45 = 2D

The Binary(Base 2) value for 50 = 110010
The Octol(Base 8) value for 50 = 62
The Hexadecimal(Base 16)value for 50 = 32

Note:- In above cpp program didn\'t use any functions entire program is written in only main function.

Thank you!

I have C++ Programming question that I do not know how to do it, can you teach me how to do it? -Explain how to convert a base 2 fraction to a base 8 or 16 frac
I have C++ Programming question that I do not know how to do it, can you teach me how to do it? -Explain how to convert a base 2 fraction to a base 8 or 16 frac
I have C++ Programming question that I do not know how to do it, can you teach me how to do it? -Explain how to convert a base 2 fraction to a base 8 or 16 frac

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site