By using C++, write a program and show the program output that convert any hexadecimal expansion to:
i) binary expansion,
ii) octal expansion, and
iii) decimal expansion.
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
#include<iostream>
#include<string.h>
using namespace std;
void decToBinary(int n)
{
// array to store binary number
int binaryNum[32];
// counter for binary array
int i = 0;
while (n > 0) {
// storing remainder in binary array
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
cout<<"Binary is ";
// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
cout << binaryNum[j];
cout<<endl;
}
void decToOctal(int n)
{
// array to store octal number
int octalNum[100];
// counter for octal number array
int i = 0;
while (n != 0) {
// storing remainder in octal array
octalNum[i] = n % 8;
n = n / 8;
i++;
}
cout<<"Octal is ";
// printing octal number array in reverse order
for (int j = i - 1; j >= 0; j--)
cout << octalNum[j];
cout<<endl;
}
// Function to convert hexadecimal to decimal
int hexadecimalToDecimal(char hexVal[])
{
int len = strlen(hexVal);
// Initializing base value to 1, i.e 16^0
int base = 1;
int dec_val = 0;
// Extracting characters as digits from last character
for (int i=len-1; i>=0; i--)
{
// if character lies in '0'-'9', converting
// it to integral 0-9 by subtracting 48 from
// ASCII value.
if (hexVal[i]>='0' && hexVal[i]<='9')
{
dec_val += (hexVal[i] - 48)*base;
// incrementing base by power
base = base * 16;
}
// if character lies in 'A'-'F' , converting
// it to integral 10 - 15 by subtracting 55
// from ASCII value
else if (hexVal[i]>='A' && hexVal[i]<='F')
{
dec_val += (hexVal[i] - 55)*base;
// incrementing base by power
base = base*16;
}
}
return dec_val;
}
// Driver program to test above function
int main()
{
char hexNum[] = "1A";
int dec=hexadecimalToDecimal(hexNum);
decToBinary(dec);
decToOctal(dec);
cout << "Decimal is "<<dec<< endl;
return 0;
}
Kindly revert for any queries
Thanks.
By using C++, write a program and show the program output that convert any hexadecimal expansion...
1. Convert the binary number 10101102 to octal, decimal, and hexadecimal numbers. 2. Convert the decimal number 236.7510 to binary,octal, and hexadecimal numbers. 3. Add the following two binary numbers: 100111102 and 011110112. Remember to show any carries that are generated along the way. 4. Repeat the previous question, but this time subtract the second binary number from the first. Remember to show any borrows that are required along the way. 5. Determine the encoding of the decimal number 28610...
(10pts) Convert the following decimal numbers to binary, octal and hexadecimal numbers a. 27 b. 650 vert the following binary numbers to decimal, octal and numbers a. 1101 b. 10101.11 (10pts) Convert the following octal numbers to decimal, binary and hexadecimal numbers (10pts) Convert the following hexadecimal numbers to decimal, binary and octal numbers a. 4F b. 3D65E
- ZOOM + To TITUITU.UUT 6 Convert each of the following octal numbers to binary, hexadecimal and decimal using the most appropriate conversion method. (a) 371 7. Convert each of the following decimal numbers to binary, octal and decimal using the most appropriate conversion method. (a) 3D65E 8. Show how a 16-bit computer using a two's complement number system would perform the following computations. (a) (2925)10 -(16850).0 = (?). (b) (16850)10-(2925)10 = (?)10
6. When you have finished, and handed in bo examination room area quickly and quietl (a) Convert decimal 135 to binary (b) Convert 76 to octal (c) Convert 541 to hexadecimal (d) Convert 37 to binary 1 (e) Use a Karnauoh man to desion a loaicd
6. When you have finished, and handed in bo examination room area quickly and quietl (a) Convert decimal 135 to binary (b) Convert 76 to octal (c) Convert 541 to hexadecimal (d) Convert 37...
In the following problems, you are asked to convert from one number base to another. I am aware that there are calculators that will do this for you. Thus, you must show all your work to get credit for these problems. 1. (3 points) - Convert the 8-binary binary expansion (0101 1001 ), to a decimal expansion. 2. (3 points) - Convert the following decimal expansion ( 124 ).o to an 8-bit binary expansion. 3. (2 points) - Convert the...
In the following problems, you are asked to convert from one number base to another. I am aware that there are calculators that will do this for you. Thus, you must show all your work to get credit for these problems. 1. (3 points) – Convert the 8-binary binary expansion ( 0110 1001 )2 to a decimal expansion. 2. (3 points) – Convert the following decimal expansion (142)10 to an 8-bit binary expansion. 3. (2 points) – Convert the following...
Convert from Decimal to Hexadecimal and Octal. If the answer is irrational, stop at four hexadecimal digits. Show your work. decimal: (0.80859375)10 hexadecimal: _____________________ decimal: (0.96875)10 octal: _____________________
Problem 1. (20 pts) Convert the following number to hexadecimal a. (5 pts)) Convert 4.2 to binary form using six digits for the fractional part b. (5 pts) Convert the result you obtained in the previous item back to decimal, with at least five digits in the fractional part. What is the absolute error that you get when the result is compared to the original number. c. (5 pts) Convert directly, without using the result in item a 4.2 to...
1. Convert the decimal number 435.64 to binary, octal, and hexadecimal. L7 2. Part A. Convert the circuit below into NAND gates. Insert or remove inverters as necessary. Part B. What is the propagation delay from any input to any output for both the original circuit and the NAND gate circuit from part A. Use 1 nS for inverters, 2 nS for NAND 3 nS for NOR, 4 ns for AND, and 5 nS for OR gates.
Show all work please!
Convert to octal. Convert to hexadecimal. Then convert both of your answer to decimal, and verify that they are the same: (a) 111011001.112 (b) 11000011001.012 4-