Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C programming) Write a function, getMask that takes three integers as parameters and returns a single integer. The first two parameters are the start and

(C programming) Write a function, getMask that takes three integers as parameters and returns a single integer. The first two parameters are the start and end bit position. The third parameter should be passed either a 0 or 1 to determine the type of mask.

The function should create an integer and set the bits specified in the first two parameters to the value in the third parameter. All other bits in the integer should be set to the opposite value of the third parameter. The function should return that integer mask.

For example, getMask(2, 6, 1); Set bits 2 to 6 to 1, set all others to zero should set the bits 2 through 6 to a 1 and all other bits to zero. This should return integer 124.

If the argument in the third parameter is anything other than 0 or 1, return 0. If the start bit position is greater than the end bit position, return 0. If the start bit position or the end bit position is greater than 31 or less than 0, return 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago