I think you are actually doing binary to hex. please do this without loops and you can use recursion. please write a working C code. Thanks
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
const char binHex[16][5] = {"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"};
//recursive method to convert hexadecimal to decimal
char * hextoBinary(char *hex,int i,int n,char *bin)
{
if(i==n)return bin;//retunring converted binary number
else
{
switch(hex[i])
{
case '0':
strcat(bin, binHex[0]);
break;
case '1':
strcat(bin, binHex[1]);
break;
case '2':
strcat(bin, binHex[2]);
break;
case '3':
strcat(bin, binHex[3]);
break;
case '4':
strcat(bin,binHex[4]);
break;
case '5':
strcat(bin, binHex[5]);
break;
case '6':
strcat(bin, binHex[6]);
break;
case '7':
strcat(bin, binHex[7]);
break;
case '8':
strcat(bin, binHex[8]);
break;
case '9':
strcat(bin, binHex[9]);
break;
case 'a':
case 'A':
strcat(bin, binHex[10]);
break;
case 'b':
case 'B':
strcat(bin, binHex[11]);
break;
case 'c':
case 'C':
strcat(bin, binHex[12]);
break;
case 'd':
case 'D':
strcat(bin,binHex[13]);
break;
case 'e':
case 'E':
strcat(bin, binHex[14]);
break;
case 'f':
case 'F':
strcat(bin, binHex[15]);
break;
default:
printf("Invalid hexadecimal number");
}
//recursive call
return hextoBinary(hex,i+1,n,bin);
}
}
int main()
{
char hex[17], *bin= (char *)malloc(sizeof(char)*65);
int i = 0;
//taking input
printf("Enter any hexadecimal number: ");
gets(hex);
for(i=0; hex[i]!='\0'; i++);//finding size of hexadecimal number
//calling method
bin = hextoBinary(hex,0,i,bin);
//displaying output
printf("Hexademial number: %s\n", hex);
printf("Binary number: %s\n", bin+3);
return 0;
}
output:
Enter any hexadecimal number: 1a
Hexademial number: 1a
Binary number: 00011010
Process exited normally.
Press any key to continue . . .
//PLS give a thumbs up if you find this helpful, its helps me alot, thanks
I think you are actually doing binary to hex. please do this without loops and you...
Convert each of the following 32 IEEE 754 single precision bit patterns to its corresponding decimal value (the bits are separated into groups of 4 to make interpretation easier). Show all of your work and include a few comments as to what you are doing at each step. 1100 0100 1011 1010 0100 1000 0000 0000 a. b. 0100 0101 1110 0010 0110 1101 0000 0000 Convert each of the following 32 IEEE 754 single precision bit patterns to its...
We have learned a famous shift cipher called Caesar Cipher. Now if we are given a plain test: THE ART OF WARAnd key = 3 (a shift by 3 letters), please give the ciphertext Given an 8 bit block P = 10101111 and a key K = 01101011, please give the result of bitwise XOR between P and K Please give the left 2 shift of the 8 bit text 01100101 Use the given a permutation table 23614857 to define...
Arduino. DEC HEX BIN(4-bits) Introducing ARDUINO 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 How many 1/0 of Port-D? How many usable 1/0 of Port-D, if Serial-Communication is in-used? What is the Arduino's pin assignment of ATMEL's PC5, PB3, & PD1*? What is the ATMEL's pin assignment of Arduino's D13*, D1, & D19? To complete the table about Number System Conversion (shown your step) 6 6 0110 7 7 0111...
Please show work! 2. Now, give it a try by converting the binary number 01110110 to decimal by filling in the same table in step 1 r of 2 Pov 128 64 32 16 Cumulative Amount 4. Now, you give it a try by converting the decimal number 131 to binary by filling in the table Power of 2 128 32 16 Bit Amount Remaining 6. Use the binary to hexadecimal table to convert the binary number 01101111 to hexadecimal...
Generate the equivalent Sim68 assembly program for the following machine code assuming it originates at address dollar 0000: 1001 0000 0100 0000 0011 0000 0100 0000 0011 0010 0010 1000 0000 0000 0000 1100 0110 0111 0000 0110 0110 1101 1111 1000 1101 0000 0100 0001 0110 0000 1111 0110 0100 1110 0100 0000 0000 0000 0000 0000 0001 0110 1111 0000 1111 1111 1111 1111 1000 0000 0000 0000 0000 0000 0000 0001
binary conversions. please help. thank you! Convert the following Binary number to Base 8 4. 1111 1001 0110 0001 1001 0101 1101 1010 1110 0010 0101 Convert the following Base 8 number to binary 5. 200076524, Convert the following Base 8 number to Base 16 6. 1177662231
3. What is the hexadecimal representation of each of the following binary numbers in signed 2’s complement? 0010 0101 0100 0011 0001 1011 0010 0100 1111 0110 1101 1001
Base no bit 0 0 Q-2 (25p): Assume that logical addresses are 16-bit long: 3 bits for segment no and 13 bits for offset. Segment table of the currently running process is given below: a) (5) How many segments can this Segment Present Modify Length process have at maximum? bit 0 00100 0111 0000 0100 0000 1000 0100 b) (15) Convert the following logical 10100 0100 0001 0010 0010 1100 1000 address to physical (real) address. 2 01100 0100 0000...
DO bit 0 1 Q-2 (25p): Assume that logical addresses are 16-bit long: 3 bits for segment no and 13 bits for offset. Segment table of the currently running process is given below: a) (5) How many segments can this Segment Present Modify process have at maximum? Length bit Base 0 0 0 0100 0111 0000 0100 0000 1000 0100 b) (15) Convert the following logical 1 1 0100 0100 0001 0010 0010 1100 1000 address to physical (real) address...
Please help with solution Write the following MARIE assembly language equivalent of the following machine language instructions 0001 0010 0000 0100 0010 0010 0000 0110 1001 0000 0000 1011 0111 0000 0000 0000