Question

(15 marks) Write a C/C++ function that will return a word consisting of the most signicant...

Write a C/C++ function that will return a word consisting of the
most signicant byte of x, and the remaining bytes of y. For operands x =
0x89ABCDEF and y = 0x76543210, this would give 0x89543210.

Homework Answers

Answer #1

#include <iostream>

using namespace std;

int main() {

int b = 0x76543210;

int a = 0x89ABCDEF;

b = b << 8;

b = b >> 8;

a = a >> 24;

a = a << 24;

int ans = a | b;

cout <<"0x" <<hex << ans <<endl;



}

==================================

SEE OUTPUT

Thanks, PLEASE COMMENT if there is any concern.

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
Write a recursive function block_count(string) to return the number of blocks consisting of the same letter...
Write a recursive function block_count(string) to return the number of blocks consisting of the same letter in the given input string. Example. >>> block_count ('AABBCCBBDDD') 5 >>>block_count ('GGABAA') 4
Write a function called count_word that takes a phrase and a word as arguments and returns...
Write a function called count_word that takes a phrase and a word as arguments and returns a count of the number of occurrences of that particular word in the phrase. The function should return an integer. Python Script in ATOM or REPL
C++: Write a function that receives a pointer to a character string consisting of only alphabets...
C++: Write a function that receives a pointer to a character string consisting of only alphabets a-z and returns the character with the maximum number of repetitions. If more than one-character repeats same number of times, return the character with smallest alphabetical order. For example, the string “Mississippi” has three repeated characters (i-4, s-4, p-2). Both ‘i’ and ‘s’ repeated 4 times but ‘i’ is alphabetically smaller hence the function should return ‘i’. Do not count repeated blanks, special characters,...
(15 marks) Write code for a function with the following prototype: /* Addition that saturates to...
Write code for a function with the following prototype: /* Addition that saturates to TMin or TMax */ int saturating_add(int x, int y); Instead of over owing the way normal two's-complement addition does, satu- rating addition returns INT_MAX when there would be positive over ow, and INT_MIN when there would be negative over ow. Saturating arithmetic is com- monly used in programs that perform digital signal processing. Your function should follow the bit-level integer coding rules above.
How would I write a c++ program from this following word problem? 3. Use the pow()...
How would I write a c++ program from this following word problem? 3. Use the pow() and sqrt() functions to compute the roots of a quadratic equation. Enter the three coefficients with a single input statement. Warning: if you give sqrt() a negative value, the function cannot produce a valid answer.
using the python Write a function oneSpaceAfterPeriod( String Parameter ) that will return a string with...
using the python Write a function oneSpaceAfterPeriod( String Parameter ) that will return a string with one space after every period. Another function twoSpaceAfterPeriod (String Parameter) that will return a string with two spaces after every period. It is also a common error to forget to capitalize the first word after a period. Write a function to correct this and return the corrected paragraph.
[C++ Language] Write a function to find out the average of an integer array and return...
[C++ Language] Write a function to find out the average of an integer array and return to the main function.
Write a function called most_common_word that takes a phrase as input and returns the most common...
Write a function called most_common_word that takes a phrase as input and returns the most common word in the phrase. If multiple words are equally common then return the first word alphabetically. Example: >>> phrase = "she sells sea shells by the sea shore" >>> unique_words(phrase) ['by', 'sea', 'sells', 'she', 'shells', 'shore', 'the'] >>>count_word(phrase, 'sea') 2 >>>count_all_words(phrase) [['by', 1], ['sea', 2], ['sells', 1], ['she', 1], ['shells', 1], ['shore', 1], ['the', 1]] >>>most_common_word(phrase) 'sea' Python Script for ATOM or REPL, (NOT...
C programming question: Write a function char isValid (char c), return a with a char value...
C programming question: Write a function char isValid (char c), return a with a char value of 1 if it is a valid char, and return 0 if it is invalid. (DO NOT USE POINTER!) valid char are '1' '2' 3' '4' '5' 'A' 'B' 'C' for example: lower case is not valid '1' is valid 'A' is valid 'B' is valid 'ABC' is not valid 'D' is not valid '9' is not valid '1234' is not valid For Testing:...
(C++) Write a function that creates a new variable on the stack. Give the variable a...
(C++) Write a function that creates a new variable on the stack. Give the variable a value of 3. Print out the value and the address of the variable within the function. Return the address of this variable, and make sure that main has a pointer set to the returned variable (int *x = func(); Print out the address of the variable and the value in the variable in main. Did this work? Did it compile? Include a comment on...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT