-1

We want to create a table in such a way that each character value is represented by a 6 bit binary value if i enter a character it should represent in binary.Can any one help me out in finding logic in c program.

000001 A 000010 B 000100 C

if i enter CA the binary digit as to be stored in format 000100000001

Thanks and Regards, Jeevan

Jeevan R
  • 1
  • 2

1 Answers1

0

include

int main() {
    long int decimalNumber, remainder, quotient;
    int binaryNumber[100], i = 1, j;
    char oChar = 'A';
    decimalNumber =oChar;
    decimalNumber = decimalNumber -64;
    quotient = decimalNumber;
    while (quotient != 0) {
        binaryNumber[i++] = quotient % 2;
        quotient = quotient / 2;
    }
    printf("Equivalent binary value of decimal number %d: ", decimalNumber);
    for (j = i - 1; j > 0; j--)
        printf("%06d", binaryNumber[j]);
    return 0;
}
Sunil B N
  • 4,159
  • 1
  • 31
  • 52