Question
IN C++ Clear Hex Digit (c command) Complete the clearHexDigit() function, so that it accepts a digit position (0-7) from the user and sets the
IN C++
Clear Hex Digit (‘c’ command) Complete the clearHexDigit() function, so that it accepts a digit position (0-7) from the user and sets the bits for that digit to zero.
SAMPLE-Enter single-letter command (or 'h' for help): c Original data value (hex) = 12349678 Enter digit number (count from the right, begin at zero): 5 Modified data value (hex) = 12049678 Decimal: 302290552 Octal: 2201113170 Hex: 12049678 Binary:
Define New Value for Hex Digit (‘d’ command) Complete the defineNewValueForHexDigit () function, so that it accepts a digit position (0-7) from the user and sets the bits for that digit to the new hex value entered by the user
SAMPLE=Enter single-letter command (or 'h' for help): d Original data value (hex) = FFFFFFFF Enter digit number (count from the right, begin at zero): 3 Enter desired new value (hex): 4 Modified data value (hex) = FFFF4FFF
Evoid clearHexDigit(unsigned int & param) 335 336 { 337 338 339 340 341 342 343 344 345 346 unsigned int digit Number; unsigned int result = 0; 11 cout < < "Original data value (hex) = < < hex < < param < < endl; digit Number = getDigit Number(); // get digit number from user // Add your code here cout < < "Modified data value (hex) = " < < hex < < result < < endl; param = result; // Pass result to caller. 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 defineNewValueForHexDigit: Inputs: Ask the user to input digit position (counting from the right, beginning with zero). param = pass-by-reference parameter Evoid defineNewValueForHexDigit (unsigned int& param) { unsigned int digit Number; unsigned int newValue; unsigned int shifted NewValue = 0; unsigned int result = 0; cout < < "Original data value (hex) = " < < hex < < param < < endl; digit Number = getDigit Number(); // get digit number from user newValue = getNewValue(); // desired value for selected digit // Add your code here. cout < < "Modified data value (hex) = " < < hex < < result < < endl; result; // Pass result to caller. param=
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