Question
in c++ language 1. (50 pts) Write the following functions and test the functions in a main program. Main function prompts the user to input
in c++ language
1. (50 pts) Write the following functions and test the functions in a main program. Main function prompts the user to input the number.
a. void DecToBin (decimal) converts the decimal into binary number, and prints out the converted binary.
b. void BinToDec (binary) converts the binary into decimal number, and prints out the converted decimal.
Remark for programming convenience:
You can treat the decimal number as usual. But for binary numbers, you can store all digits into a std::vector. For Problem a, recall the conversion from decimal to binary, you keep the remainder after each division. Hence you can record each remainder in a std::vector by using YourVector.push_back(). Finally, print out the results (Notice that if you use push_back(), you may need to print from the end to the start of the vector. That is, from YourVector.size() to 1.).
For Problem b, you can use std::vector as the argument of BinToDec. Recall the conversion from binary to decimal, using vector provides some convenience. That is, the index of vector elements can help in the conversion.
2. (50 pts) Write the following functions and test the functions in a main program
a. void markParityBits(sizeofVector) marks all the parity positions in the vector (length of which is prompted by the user)
b. void calParityBits(index) calculates the parity bits for each of the index in the vector Main function prompts the user the size of the data vector and also the data bits of the vector.
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