Question

1. [17 pts, 1/line] Modify the following code to display the binary information stored at a location in memory referred named myVar: #inciude <stdio.h> #define N 8 int main0 //Enter the number of bits here char myVar/Declare variable here int i; printf (%c, * ( (long*) &myVar) &1<<i? 1 : 0 ) ; printf (n return 0

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

#define N 8

int main() {
    char myVar = 'N';
    int i;
    for(i = N-1; i >= 0; i--)
        printf("%c", *((long *) &myVar) & 1 << i ? '1' : '0');
    printf("\n");
    return 0;
}

01001110

N\;in\;ascii\;is\;78.\;and\;78\;in\;binary\;is\;01001110

so,\;the\;output\;is\;correct

I\;didn't\;have\;to\;make\;any\;changes\;to\;the\;code.\;It's\;working\;correctly!

Please let me know if you need to me make any changes.

Add a comment
Know the answer?
Add Answer to:
1. [17 pts, 1/line] Modify the following code to display the binary information stored at a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code...

    Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed array, 32-bit signed array and 32-bit signed array. 2) Fill in all the blanks in Table 1 using your completed code, following the hints provided within the table. 3) Fill in all the blanks in Table 2 using your completed code, following the hints provided within the table. C++ Program #include <stdio.h> #include <iostream> int...

  • A)Correct this code and explain what was corrected // C code - For Loop / Array...

    A)Correct this code and explain what was corrected // C code - For Loop / Array Population // This program will populate integers into an array, and then display those integers. // Developer: Johnson, William CMIS102 // Date: Mar 4, 2020 // Global constants #define INTLIMIT 10 #include <stdio.h> // This function will handle printing my name, class/section number, and the date void printStudentData() { char fullName[19] = "William J. Johnson"; char classNumber[9] = "CMIS 102"; char sectionNumber[5] = "4020";...

  • // C code // If you modify any of the given code, the return types, or...

    // C code // If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // Yyou are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of patients struct patientList {    struct patient *patient;    struct patientList *next; } *list = NULL;  ...

  • How do i finish this code: #include <stdio.h> int main() { long long decimal, tempDecimal, binary;...

    How do i finish this code: #include <stdio.h> int main() { long long decimal, tempDecimal, binary; int reminder, weight = 1; binary = 0.0; //Input decimal number from user printf("Enter any decimal number: "); scanf("%lld", &decimal); // Since we do not want change the value of decimal in the code // let us use tempDecimal to store the value of decimal tempDecimal = decimal; printf("\n\n"); // Let us use while loop first to implement printf("while loop part:\n"); /**************START FROM HERE...

  • I need to modify below code to have output like: Example: RBGY [ You have 1...

    I need to modify below code to have output like: Example: RBGY [ You have 1 white flag and you have 1 red flag] Example: CCGG [ You have 0 white flag and you have 1 red flag] ================================== #include <stdio.h> #include <string.h> #include <time.h> #include <stdlib.h> #define SIZE_STRING 4 #define SIZE_STRING_LONG 15 int main(int argc, char *argv[]){ if(argc != 2) { printf("Usage: ./main <scComputer>"); exit(0); } char szUser[SIZE_STRING_LONG]; char *szComputer = argv[1]; int counter=0; int colour=0; int position=0; char...

  • Please help in C: with the following code, i am getting a random 127 printed in...

    Please help in C: with the following code, i am getting a random 127 printed in front of my reverse display of the array. The file i am pulling (data.txt) is: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 when the reverse prints, it prints: 127 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 not sure why...please...

  • Please Modify the following program, paste your code and show the execution result capture /** *...

    Please Modify the following program, paste your code and show the execution result capture /** * Basic execl() Usage. * * By walking through this example you’ll learn: * - How to use execl(). * - What happens to the process that invoked execl(). * */ #include #include int main(int argc, char* argv[]){ printf("%s executing `ls -l`.\n", "Before"); // HINT: The /bin/ls -l should be executed. execl(); printf("%s executing `ls -l`.\n", "After"); return 0; }

  • Memory Consider a process running the following program #include estdlib.h> #include #define const char* int int...

    Memory Consider a process running the following program #include estdlib.h> #include #define const char* int int <stdio.h> TO PRINT toPrintCPtr "Good luck!" TO PRINT; main for (i -0; i < sizeof (TO PRINT)-1; i++) printf("%c %c\n", toPrintCPt r [1], toupper(toPrintCPt r [i])); return(EXIT SUCCESS); Please tell where the following objects are stored in memory. Your choices are a. ROM BIOS b. kernal Memory (the OS) c. shared library memory (the glibc library) d. .text segment e. .rodata segment f. .data...

  • I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves...

    I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves the array of structures to file. It is already implemented for you. // You should understand how this code works so that you know how to use it for future assignments. void save(char* fileName) { FILE* file; int i; file = fopen(fileName, "wb"); fwrite(&count, sizeof(count), 1, file); for (i = 0; i < count; i++) { fwrite(list[i].name, sizeof(list[i].name), 1, file); fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...

  • Please help modify my C program to be able to answer these questions, it seems the...

    Please help modify my C program to be able to answer these questions, it seems the spacing and some functions arn't working as planeed. Please do NOT copy and paste other work as the answer, I need my source code to be modified. Source code: #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { char title[50]; char col1[50]; char col2[50]; int point[50]; char names[50][50]; printf("Enter a title for the data:\n"); fgets (title, 50, stdin); printf("You entered: %s\n", title);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT