Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question is kind of confusing so I include 2 test cases. Please write in c. First: Bit functions (35 Points You have to write

image text in transcribedimage text in transcribedThe question is kind of confusing so I include 2 test cases. Please write in c.

First: Bit functions (35 Points You have to write a program that will read a number followed by a series of bit operations from a file and perform the given operations sequentially on the number. The operations are as follows set(x, n, v)sets the nth bit of the number x to v comp(x, n)sets the value of the nth bit of x to its complement (1 if 0 and 0 otherwise) get (x, n) The least significant bit (LSB) is considered to be index 0 returns the value of the nth bit of the number x Input format: Your program the value of the number to be manipulated. For the function calls this number can be considered x. This number should be considered an unsigned short. The following lines will contain the op- erations to manipulate the number. The format of the operations will always be the command followed by 2 numbers with tabs in between each part. For the set(x, n. v) command, the value of the second number will always be either 0 or 1. For the comp(x, n) and get(x, n) command the value of the second number will always be 0 and can be ignored will take the file name as input. The first line in the file provides Output format: Your output will be the resulting value of the number x after each operation, each on a new line. The get(x, n) function should only print the value of the nth bit as the value of x does not change. Example Execution: For example, a sample input file "filel.txt" contains: get 0 0 comp 0 set 1 1 The result of the sample run is: $./first filel.txt 4

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

1. In what ways has flexible working revolutionised employment?

Answered: 1 week ago