Question

Create a program in C++ which checks for 1 bit errors in an error detection system...

Create a program in C++ which checks for 1 bit errors in an error detection system which uses a single parity bit (the single parity bit checks the parity of all bits in each code). Each code is 8 bits (7 bits for data and one for parity). The code distance is 2. You program should check for even parity (parity bit is 1 for even parity). Your program should allow the user to input a single unsinged decimal value up to 255, and then output whether there is a 1 bit error or not.

Homework Answers

Answer #1

if the number of 1;s are even then there is no error and if there are odd numbers of 1's there is error

because parity bits are used to maintain even numbers of 1's

C++ code :

int main()
{
int input;
cin>>input;
int cnt=0;
while(input!=0)
{
   int r=input%2;
   if(r==1)
   cnt++;
   }
   if(cnt%2==1)
   cout<<"ERROR OCCURED";
   else
   cout<<"NO ERROR";
return 0;
}

PLEASE UPVOTE

Know the answer?
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
Similar Questions
Design an even parity detection circuit. A parity bit is an error checking mechanism. Your circuit...
Design an even parity detection circuit. A parity bit is an error checking mechanism. Your circuit will count the number of 1’s in a stream of bits. If the number of 1’s is even, the circuit turns on an output called Y. Assume a single bit at each cycle – call the input X. Do not use an accumulator or counter. Design the even parity detection circuit using J-K flip-flops. Your answer must include: a. The state diagram. b. The...
Create a C program that evaluates the function 3x + 7. Your input will consist of...
Create a C program that evaluates the function 3x + 7. Your input will consist of a number of lines, each containing a single integer number. For each number x that is provided in the input, you should output 3x + 7 as a single integer number. Each number your program prints has to occupy a separate line. No other character should be sent to the output other than the digits of the number (and possible sign) and the newline...
The Problem Write a C or C++ program which performs specific operations on bits. The user...
The Problem Write a C or C++ program which performs specific operations on bits. The user will specify a value The user can then set, test, or toggle individual bits in the initial value. Input Your program will prompt the user for: An inital value in hexadecimal. This value may be up to 32 bits (eight hexadecimal digits) long. If the user-supplied value is less than eight characters in length, assume the additional digits are zero and are on the...
Create a C program that evaluates the function 3x + 7. Your input will consist of...
Create a C program that evaluates the function 3x + 7. Your input will consist of a number of lines, each containing a single integer number. For each number x that is provided in the input, you should output 3x + 7 as a single integer number. Each number your program prints has to occupy a separate line. No other character should be sent to the output other than the digits of the number (and possible sign) and the newline...
Create a program to ask the user for an integer number, positive only. If the number...
Create a program to ask the user for an integer number, positive only. If the number is between 0 and 255, printout the number in binary format to the screen. This will involve checking the bits, one by one, starting from the most significant place: 128. Use c++ 1. Modify the program to find the binary number, using a FOR loop, instead of the manual checking of each bit separately 2. What are the bitwise XOR and INVERSION operators? Find...
Create the following program using C language in Microsoft Visual Studios: Create a program that uses...
Create the following program using C language in Microsoft Visual Studios: Create a program that uses a function that will print to the user the mean, high value, and low value of 5 input values into your function. The output of the function should pass the mean.
Consider a noisy communication channel, where each bit is flipped with probability p (the probability that...
Consider a noisy communication channel, where each bit is flipped with probability p (the probability that a bit is sent in error is p). Assume that n−1 bits, b1,b2,⋯,b(n−1), are going to be sent on this channel. A parity check bit is added to these bits so that the sum b1+b2+⋯+bn is an even number. This way, the receiver can distinguish occurrence of odd number of errors, that is, if one, three, or any odd number of errors occur, the...
q7.3 Fix the errors in the code (in C) //This program uses a function called CharacterScan...
q7.3 Fix the errors in the code (in C) //This program uses a function called CharacterScan to read a char from the user //The function must take an int pointer as a parameter //The program should print the char and ascii code for each character the user enters //The program should only exit whe nthe user enters escape #include <stdio.h> char CharacterScan(int*); int main(void){ while(1){ int aCode; int* iPtr; char* c = CharacterScan(iPtr); if(aCode) break; else printf("%c is ASCII code...
I am to create three different versions of the following C program code below that implements...
I am to create three different versions of the following C program code below that implements the conversion of unsigned binary numbers into decimal (Base 2 to Base 10 conversion). Version 1: Complete the C program ”bin2dec ver1.c” that implements binary to decimal conversion. The maximum number of binary bits is 32. The program is made of the functions ”unsigned binary to decimal(const char *str)”and ”main”. The parameter ”str” passed to this function points to a C string comprising only...
Now we want to display which error was thrown in our voting program. ( BOTH QUESTIONS...
Now we want to display which error was thrown in our voting program. ( BOTH QUESTIONS ARE PYTHONS PROGRAMS) Add the appropriate code to the try/except statement so the exception is displayed. Run the program and, when prompted, enter the word 'old' so your output matches the output under Desired Output. # Set the variable age = input("What is your age?") # Insert a try/except statement # here when you convert the input # to a number using int() try:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Nursing Care of Patient with Peptic Ulcer Disease Abstract: Cedric Filmore, age 40, is transferred to...
    asked 2 minutes ago
  • describe the three fiscal policy tools at the government's disposal to stimulate or contract the economy....
    asked 25 minutes ago
  • i) Write the condensed electron configurations for the following ions: (a) Ca+ (b) S2- (c) V2+...
    asked 25 minutes ago
  • In Java a function can call itself(we may explore more about this later in the course).  This...
    asked 38 minutes ago
  • Write a short program,Java, that implements the Caesar substitution cipher with k=3. That is, each letter...
    asked 40 minutes ago
  • Design a function named findMax that accepts two integer values as arguments and returns the value...
    asked 46 minutes ago
  • In MIPS, I am trying to create an array of 7 words that can either be...
    asked 47 minutes ago
  • Cash, $2,000 Accounts Receivable, $1,250 Professional Equipment, $10,200 Office Equipment, $5,500 Accounts Payable, $3,500 P. Palmer,...
    asked 48 minutes ago
  • Add two more statements to main() to test inputs 3 and -1. Use print statements similar...
    asked 49 minutes ago
  • C++ program called that reads a string and check if it’s well-formed or not. ex== The...
    asked 1 hour ago
  • 1: Describe five functions of nonverbal communication. (Creating and maintaining relationships, Regulating Interaction, Influencing others, Concealing/deceiving,...
    asked 1 hour ago
  • Trucks that travel on highways have to stop at various locations to be weighed and inspected...
    asked 1 hour ago