In: Computer Science
yur quetion is vague as per my understanding i am giving you various cases in my answer hopin that one of these will meet ur requirement
case 1:
converting a decimal to hexadecimal c code
#include<stdio.h>
int main() {
long int decimalNumber,remainder,quotient;
int i=1,j,temp;
char hexadecimalNumber[100];
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0) {
temp = quotient % 16;
//To convert integer into
character
if( temp < 10)
temp =temp + 48; else
temp = temp + 55;
hexadecimalNumber[i++]= temp;
quotient = quotient / 16;
}
printf("Equivalent hexadecimal value of decimal number
%d: ",decimalNumber);
for (j = i -1 ;j> 0;j--)
printf("%c",hexadecimalNumber[j]);
return 0;
}
case 2: << is left shift operator we cannot add numbers with that instead it operates on the binary values of given number
example to explain <<
#include<stdio.h>
int main()
{
int a = 60;
printf("\nNumber is Shifted By 1 Bit : %d",a << 1);
printf("\nNumber is Shifted By 2 Bits : %d",a << 2);
printf("\nNumber is Shifted By 3 Bits : %d",a << 3);
return(0);
}
output is
Number is Shifted By 1 Bit : 120
Number is Shifted By 2 Bits : 240
Number is Shifted By 3 Bits : 480
case 3:
if you want to form a hexadecimal from the numbers in array as given then simple output formaing is sufficient
char arr[10]
arr[0]='0'
arr[1]='x'
arr[2]='0'
j=3;
for(i=0;i<4;i++)
{
arr[j]=(char)a[i%4]; #random value from array
j++
}