Question: I a writing a program that will convert the numbers into binary form then print a letter. 000 0000 0000 0000 0000 00000001 to the

I a writing a program that will convert the numbers into binary form then print a letter.

000 0000 0000 0000 0000 00000001 to the letter a (lowercase)

000 0000 0000 0000 0000 00000010 o the letter b (lowercase)

000 0000 0000 0000 0000 00000100 is the letter c

and if the most LHS bit is a 1, it will be 67108865 and 100 0000 0000 0000 0000 00000001 in binary wich prints A. Likewise a capital B is 100 0000 0000 0000 0000 00000010 and 6710886

I did everything right, except i'm having a problem with the uppercase letters. can someone help me print the value

A if the user enters 67108865 ? Thanks!

#include #include #include #include #include using namespace std; int to_Binary(char *argv[],int number_Of_Nums){

{ int count =0; for (count = 0; count < number_Of_Nums; count++) {

int deci = atoi(argv[count]); int array[32]; int n = 0;

for(n=31; n>=0; n--) { if(deci>=pow(2,n)){ array[n]=1; deci = deci-pow(2,n); } else array[n] = 0; } //printf(" ");

//next convert binary to letter value int temp=0; int i,count=0;

for( n = 31; n >=0; n-- ){ // added to display the number from the first MSB As 1 if(array[n] != 1 && count==0) { continue; } else { count = 1; printf( "%d", array[ n ] ); } }

for(i=0;i<=30;i++) { if (array[i]==1 && array[31]==0) temp= i+97; if(array[i]==1 && array[31]==1) temp= i; }

printf("%c",(char)temp); // this line prints the ASCII value of charcters printf("ASCII value of %c = %d",(char)temp, (char)temp);

} }

printf(" "); return 0; }

int main (int argc, char *argv[]) { int count;

to_Binary(argv+1,argc-1);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!