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 -

     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

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

converting a base 2 fraction to base 8 or 16 is easy after you have converted it to base 10.

For instance, 0.0112 = 0 × 2-1 + 1 × 2-2 + 1 × 2-3 = 0 + 1/4 + 1/8 = 0 + 0.25 + 0.125 = 0.37510.

And now you can convert 0.37510 to base 8 or 16 by simply following the given procedure

1.12 = 1*20 +1*2-1 = 1+0.5 = 1.5

1.112 = 1*20 +1*2-1 + 1*2-2 = 1+.5+.25 = 1.75

1.1112 = 1*20 +1*2-1 + 1*2-2 + 1*2-3 = 1.875

-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.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>


long binary_code(int);
double hexadecimal_code(int);
double octal_code(int);

main()
    {

       clrscr();

       int number;

       cout<<\"\ Decimal Number\"<<endl;
       cout<<\"\ For binary numbers ,enter from( 0 ---> 1023 ) \"<<endl;

       cout<<\"\ \ Enter the Decimal number = \";
       cin>>number;

       cout<<\"\ Binary Number\"<<endl;
       cout<<\"\\t Binary Number = \"<<binary_code(number)<<endl;

       cout<<\"\ Hexadecimal Code\"<<endl;
       cout<<\"\\t Hexadecimal Code = \"<<Hexadecimal_code(number)<<endl;

       cout<<\"\ Octal Code\"<<endl;
       cout<<\"\\t Octal Code = \"<<octal_code(number)<<endl;

       getch();
       return 0;
    }

long binary_code(int number)
    {
       int count=0;
       int resulting_array[25];
       int remainder;
       int qutiont;
       int size=0;

       long binary_number=0;
       long sum=0;
       longbase=1;

       while(number>0)
      {
         qutiont=number/2;
         remainder=number%2;
         number=qutiont;
         resulting_array[count]=remainder;

         size++;
         count++;
      }

       for(int j=0;j<size;j++)
      {
         sum=resulting_array[j]*base;
         base=base*10;
         binary_number+=sum;
      }

       return binary_number;
    }

double Hexadecimal_code(int number)
    {
       int count=0;
       int resulting_array[25];
       int remainder;
       int qutiont;
       int size=0;

       double Hexadecimal_number=0;
       double sum=0;
       doublebase=1;

       while(number>0)
      {
          qutiont=number/5;
          remainder=number%5;
          number=qutiont;
          resulting_array[count]=remainder;

          size++;
          count++;
      }

       for(int j=0;j<size;j++)
      {
         sum=resulting_array[j]*base;
         base=base*10;
         Hexadecimal_number+=sum;
      }
       return Hexadecimal_number;
    }


double octal_code(int number)
    {
       int count=0;
       int resulting_array[25];
       int remainder;
       int qutiont;
       int size=0;

       double octal_number=0;
       double sum=0;
       doublebase=1;

       while(number>0)
      {
          qutiont=number/8;
          remainder=number%8;
          number=qutiont;
          resulting_array[count]=remainder;

          count++;
          size++;
      }

       for(int j=0;j<size;j++)
      {
         sum=resulting_array[j]*base;
         base=base*10;
         octal_number+=sum;
      }
       return octal_number;
    }

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