MUST BE IN C++!!!!!!!!!!!!!!!! Since communication channels are often noisy, num
ID: 3763155 • Letter: M
Question
MUST BE IN C++!!!!!!!!!!!!!!!!
Since communication channels are often noisy, numerous ways have
been devised to ensure reliable data transmission. One successful
method uses a checksum. A checksum for a message can be computed by
summing the integer codes of the characters in the message and
finding the remainder of this sum divided by 64. The integer code
for a space character is added to this result to obtain the
checksum. Since this value is within the range of the displayable
characters, it is displayed as a character as well. Write a program
that accepts single-line messages ending with a period and displays
the checksum character for each message. Your program should
continue displaying checksums until the user enters a line with
only a period.
Explanation / Answer
#include <stdio.h>
int main ()
{
while(1)
{
char str[50] = {0};
int num = 0;
char final_val;
printf("Line: "); // Request Line
scanf("%s", str); // Read in Line
int i;
for (i = 0; i<=49; i++)
{
num+=str[i];
}
num = num%64;
final_val = num;
num = 0;
printf(" Checksum: %c", final_val);
printf(" ");
return(0);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.