Answered You can hire a professional tutor to get the answer.

QUESTION

Dear Tutor, from below code, I don't understand // ch = j; and ch = 7; if ch has k then, ascii codes will be shifted?

Dear Tutor,from below code, I don't understand // ch <<= j; and ch >>= 7;if ch has k then, ascii codes will be shifted? ======================================================#include <stdio.h> // read/write() is prototyped in it#define WHICH_SYMBOL(X) X == 1 ? '1' : '0'void ShowBits(char arr[], int size){unsigned char ch;char symbol;int i, j;for( i = 0; i < size; i++ ){write( 1, &arr[i], 1 );write( 1, " ", 2 );for ( j = 0; j < 8; j++ ){ch = arr[ i ];ch <<= j;ch >>= 7;symbol = WHICH_SYMBOL(ch);write( 1, &symbol, 1 );write( 1, " ", 1 );}write( 1, "n", 1 );}write( 1, "n", 1 );}main(){// useful for loopingchar name[20], mask_in[20], mask_out[20];write( 1, "Enter your last name: ", 22 ); // prompt to enterfflush( stdout );// get keyboard input// not counting the last enter keywrite( 1, "Name entered is ", 16 );write( 1, name, len );write( 1, "n", 1 );// Part 1ShowBits( name, len );// Part 2for ( i=0; i< len; i++ ) mask_in[ i ] = name[ i ] | name[ 0 ];ShowBits( mask_in, len );// Part 3mask_out[ 0 ] = name[ 0 ];for ( i=0; i< len; i++ ) mask_out[ i ] = name[ i ] & name[ 0 ];ShowBits( mask_out, len );}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question