Answer to Question #198556 in C for zojee Arsal

Question #198556

write a program that uses a two dimensional of 256*8 to store 8 bit binary representations of each of the characters of ASCII character set.


1
Expert's answer
2021-05-25T14:09:52-0400
#include <stdio.h>

int main()
{
    int i, j;
    char data[256][8];

    for(i = 0; i < 256; ++i)
    {
        char tmp = (char) i;
        
        for(j = 0; j < 8; ++j)
        {
            data[i][j] = tmp & 0x01 ? '1' : '0';
            tmp >>= 1;
        }
    }

    for(i = 0; i <= 255; ++i)
    {
        printf("%d\t%c\t", i, i);
        
        for(j = 7; j >= 0; --j)
        {
            printf("%c", data[i][j]);
        }

        printf("\n");
    }

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS