Answered step by step
Verified Expert Solution
Question
1 Approved Answer
My code doesnt work and when i compile i get lab 3 1 . cpp: 4 0 : 1 2 : warning: comparison between signed
My code doesnt work and when i compile i get labcpp::: warning: comparison between signed and unsigned integer expressions Wsigncompare
if bit getBitHammingChar offendingBit ;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labcpp::: warning: comparison between signed and unsigned integer expressions Wsigncompare
if bit getBitHammingChar offendingBit ;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labcpp::: warning: comparison between signed and unsigned integer expressions Wsigncompare
if bit getBitHammingChar offendingBit ;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labcpp::: warning: comparison between signed and unsigned integer expressions Wsigncompare
if bit getBitHammingChar offendingBit ;
this is the code :
#include
#include
using namespace std;
const string ID "Stellar Carroll CS Lab ;
Function to get the value of a specific bit in a short integer
int getBitshort num, int pos
return num pos & ;
Function to set a specific bit in a char variable
char setBitchar ch int pos, int val
if val
return ch pos;
else
return ch & ~ pos;
int main
short HammingChar;
uint bit bit bit bit offendingBit;
char ch;
cout ID endl;
Read an unknown number of short ints, each representing a Hamming character
while cin HammingChar
offendingBit ;
Use the formula to calculate parity bit
bitgetBitHammingChar getBitHammingChar getBitHammingChar getBitHammingChar getBitHammingChar;
Use the formulas to calculate parity bits and
bitgetBitHammingChar getBitHammingChar getBitHammingChar getBitHammingChar getBitHammingChar;
bitgetBitHammingChar getBitHammingChar getBitHammingChar;
bitgetBitHammingChar getBitHammingChar getBitHammingChar;
if bit getBitHammingChar offendingBit ;
if bit getBitHammingChar offendingBit ;
if bit getBitHammingChar offendingBit ;
if bit getBitHammingChar offendingBit ;
Debug output for the offending bit position
cout "Debug: offendingBit offendingBit endl;
If offendingBit is not correct the bit and build the character
if offendingBit
int correctedBitPos offendingBit;
HammingChar HammingChar correctedBitPos ;
Build the character from the corrected HammingChar
ch ;
ch setBitch getBitHammingChar;
ch setBitch getBitHammingChar;
ch setBitch getBitHammingChar;
ch setBitch getBitHammingChar;
ch setBitch getBitHammingChar;
ch setBitch getBitHammingChar;
ch setBitch getBitHammingChar;
Output the corrected ASCII character
cout ch;
cout endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started