Hello. Please answer the attached C programming question correctly. The attached code has to be changed so that it can print a decoded version of the binary number list. Please do not use very advanced syntax to solve the problem. Also, please create a complete file header based on the file header style picture.  *If you change the attached code correctly, do not use very advanced syntax, and create the file header, I will give you a thumbs up. Thanks. —----------------------------------------------------------------------------------------------------------------- Code That Needs to Be Changed: #include int bintodec(char *str) {     int x = 0;     for(int i = 0; str[i] != '\0'; i++) {         x = (str[i] - '0') + x * 2;     }     return x; } void dectobin(int x, char *bin) {     for(int i = 0; i < 7; i++) {         bin[i] = '0';     }     bin[7] = '\0';     int i = 6;     while(x != 0) {         bin[i] = (x % 2) + '0';         x /= 2;         i--;     } } int main() {     int num=12;     char binaryNum[]="00101100";     char binaryRep[8];     int decRep;     int i, j;     dectobin(num, binaryRep);     decRep = bintodec(binaryNum);     printf(" Binary representation of %d is %s.\n",num, binaryRep);     printf(" Decimal representation of %s is %d.\n",binaryNum, decRep);     return 0; } —------------------------------------------------------------------------------------------------------------------ Question: Assume you received a text message in binary, and you need to decode the message. char *binaryMsg = "0101100101101111011101010010000001100110011011110111010101101110011001000010000001110100011010000110010100100000011100110110010101100011011100100110010101110100001000000110110101100101011100110111001101100001011001110110010100101110"; The message is the ASCII code of some characters. Your task is to convert every eight bits of the message to a decimal number. The decimal number is the ASCII code of the character that you need to print. When you print all characters, you will see the message. *Further instructions are in the pictures.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello. Please answer the attached C programming question correctly. The attached code has to be changed so that it can print a decoded version of the binary number list. Please do not use very advanced syntax to solve the problem. Also, please create a complete file header based on the file header style picture. 

*If you change the attached code correctly, do not use very advanced syntax, and create the file header, I will give you a thumbs up. Thanks.

—-----------------------------------------------------------------------------------------------------------------

Code That Needs to Be Changed:

#include <stdio.h>

int bintodec(char *str) {

    int x = 0;

    for(int i = 0; str[i] != '\0'; i++) {

        x = (str[i] - '0') + x * 2;

    }

    return x;

}

void dectobin(int x, char *bin) {

    for(int i = 0; i < 7; i++) {

        bin[i] = '0';

    }

    bin[7] = '\0';

    int i = 6;

    while(x != 0) {

        bin[i] = (x % 2) + '0';

        x /= 2;

        i--;

    }

}

int main()

{

    int num=12;

    char binaryNum[]="00101100";

    char binaryRep[8];

    int decRep;

    int i, j;

    dectobin(num, binaryRep);

    decRep = bintodec(binaryNum);

    printf(" Binary representation of %d is %s.\n",num, binaryRep);

    printf(" Decimal representation of %s is %d.\n",binaryNum, decRep);

    return 0;

}

—------------------------------------------------------------------------------------------------------------------

Question:

Assume you received a text message in binary, and you need to decode the message.

char *binaryMsg = "0101100101101111011101010010000001100110011011110111010101101110011001000010000001110100011010000110010100100000011100110110010101100011011100100110010101110100001000000110110101100101011100110111001101100001011001110110010100101110";

The message is the ASCII code of some characters. Your task is to convert every eight bits of the message to a decimal number. The decimal number is the ASCII code of the character that you need to print. When you print all characters, you will see the message.

*Further instructions are in the pictures. 

******** *************
* Project : <Name of project | assignment>
* File
<Name of source code file>
:
* Date
: <Date created>
*
* Description : (Narrative description, not code)
*
1) What is the purpose of the code; what problem does the code solve.
* 2) What algorithms, techniques, etc. are used in implementing the data structures.
*
*
Code Changes: <Description | date of modifications>
********************************************************/
Transcribed Image Text:******** ************* * Project : <Name of project | assignment> * File <Name of source code file> : * Date : <Date created> * * Description : (Narrative description, not code) * 1) What is the purpose of the code; what problem does the code solve. * 2) What algorithms, techniques, etc. are used in implementing the data structures. * * Code Changes: <Description | date of modifications> ********************************************************/
1. You need to copy the first eight bits of binaryMsg to another string. Then, send that string
for bintodec function and save it in an integer named decRep. Finally, print decRep as a
character.
2. Then continue step 2 for the next eight bits of binaryMsg.
3. Repeat step 2 and 3 till you get to '\0' at the end of binaryMsg.
Hint:
You need a string to send for bintodec function. You can use strncpy to copy a part of
binaryMsg to a temporary string and send it for bintodec function.
char binaryRep [8];
int decRep;
strncpy(binaryRep, binaryMsg + (0*8), 8); //copies the first byte of binaryMSG to binaryRep
decRep = bintodec (binaryRep); // You can print the character value of decRep for the first character o
of the secret message
strncpy(binaryRep, binaryMsg + (1*8), 8); //copies the second byte of binaryMSG to binaryRep
decRep = bintodec (binaryRep); // You can print the character value of decRep for the second character
of the secret message
strncpy(binaryRep, binaryMsg + (2*8), 8); //copies the third byte of binaryMSG to binaryRep
decRep = bintodec (binaryRep); // You can print the character value of decRep for the third character o
of the secret message
you need to repeat this code up to reach '\0' at the end of binary Msg.
Transcribed Image Text:1. You need to copy the first eight bits of binaryMsg to another string. Then, send that string for bintodec function and save it in an integer named decRep. Finally, print decRep as a character. 2. Then continue step 2 for the next eight bits of binaryMsg. 3. Repeat step 2 and 3 till you get to '\0' at the end of binaryMsg. Hint: You need a string to send for bintodec function. You can use strncpy to copy a part of binaryMsg to a temporary string and send it for bintodec function. char binaryRep [8]; int decRep; strncpy(binaryRep, binaryMsg + (0*8), 8); //copies the first byte of binaryMSG to binaryRep decRep = bintodec (binaryRep); // You can print the character value of decRep for the first character o of the secret message strncpy(binaryRep, binaryMsg + (1*8), 8); //copies the second byte of binaryMSG to binaryRep decRep = bintodec (binaryRep); // You can print the character value of decRep for the second character of the secret message strncpy(binaryRep, binaryMsg + (2*8), 8); //copies the third byte of binaryMSG to binaryRep decRep = bintodec (binaryRep); // You can print the character value of decRep for the third character o of the secret message you need to repeat this code up to reach '\0' at the end of binary Msg.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education