1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kykrilka [37]
3 years ago
10

Suppose we number the bytes in a w-bit word from 0 (least significant) to w/8 − 1 (most significant). Write a code for the follo

wing C function, which will return an unsigned value in which byte i of argument x has been replaced by byte b:
unsigned replace_byte (unsigned x, int i, unsigned char b);
Computers and Technology
1 answer:
castortr0y [4]3 years ago
4 0

Answer and Explanation:

// header file

#include <stdio.h>

// function to replace value

unsigned replace_byte(unsigned x,int i,unsigned char b){

  char* p = (char*)(&x);

  p[i] = b;

  return x;

}

int main(){

  // declare variables

  unsigned n = 0x12345678;

  unsigned r1,r2;

  // display result

  printf("%x\n%x\n",replace_byte(n,2,0xAB),replace_byte(n,0,0xAB));

}

output

                                                                                                                                               12ab5678                                                                                                                                                    

123456ab                                                                                                                                                    

You might be interested in
Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y
kirill [66]

// Here is the required switch statement on response character

switch(response){

case 'y': // case to check if the response is y

cout<<" Your request is being processed ";

case 'n': // case to check for n

cout<<" Than you, anyway for your consideration";

case 'h': // case to check for h

cout<<"Sorry \, no help is currently available.";

default : // default case

cout<< Invalid entry: please try again.";

}

6 0
3 years ago
Joe, a user, has just installed his first home wireless router. Which of the following tasks should be considered to help secure
MakcuM [25]

Answer:

Update the unit firmware.

Explanation:

Updating unit firmware means update the information related to the network that is newly installed on the wireless router. The purpose of this change is to update the devices with new network alterations to work with efficiency and better security. As things are updating on daily basis, so the manufacturer makes the devices, reprogram able to meet the requirement of the future by updating the program in firmware unit. By updating device means this will be to fix the bugs that can be occur in modern era. This will make the device more secure.

5 0
3 years ago
Which of the following is not an advanced strategy you may use to help you conduct a search on the Internet?
Leno4ka [110]

Answer:

3-using a wild card in your search

7 0
4 years ago
What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from r
mixer [17]

Answer:

What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise)? - sll$t0, $t3, 9# shift $t3 left by 9, store in $t0

srl $t0, $t0, 15# shift $t0 right by 15

Explanation:

The shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise) is shown below:

sll$t0, $t3, 9# shift $t3 left by 9, store in $t0

srl $t0, $t0, 15# shift $t0 right by 15

4 0
3 years ago
To what are multiple servers arranged in racks related
qaws [65]

Various number of servers placed in racks are related to Rack servers in data center.

Explanation:

In data center commonly used server is Rack servers.  Servers are being arranged in the mounted racks are generally called as rack servers in the data center. Internal fans are being fitted inside the racks make the servers to make a good airflow and maintain the cooling. There are different types of racks available the user can choose based on their requirement.

5 0
3 years ago
Read 2 more answers
Other questions:
  • The set of specific, sequential steps that describe exactly what a computer program must do to complete the work is called a(n _
    14·1 answer
  • In 2–3 sentences, describe how you would find a certain record.
    11·2 answers
  • _____ is the network protocol that deals with the routing of packets through interconnected networks to the final destination.
    9·1 answer
  • Which option allows you to customize the order of your data ?
    8·2 answers
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    8·1 answer
  • Windows _ is a built-in tool that uses libraries, or groups of related files, to enable you to search for programs, files, or fo
    13·1 answer
  • What is the purpose of the domain name? The domain name is an example of a service provider. The domain name .gov.nz is an examp
    15·2 answers
  • Which features of words are used to separate numbers and texts into columns
    11·1 answer
  • Which engineer may design a GPS for a vehicle?
    15·1 answer
  • Q1) What would be the output of the program shown in the figure?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!