Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem / Exercise The purpose of this lab is to get experience with the bitwise not operator, the left shift operator, and the right shift

image text in transcribed

image text in transcribed

Problem / Exercise The purpose of this lab is to get experience with the bitwise not operator, the left shift operator, and the right shift operator. You will implement a C program that will process command line arguments, as shown in the examples, in two ways: 1. a flag representing bitwise not and a bit string; 2. a bit string, a flag representing a left shift operator or a right shift operator, and an amount to left shift or right shift. Your C program should output the correct result of the appropriate operator in binary and in base-10 as shown in the examples. The three possible flags for this assignment are -not to denote the operator, -leftshift to denote the operator, and -rightshift to denote the operator. Let n be the length of the bit string inputted on the command line. You should assume all of the following for this assignment. - 1n64. - All of the bit strings in this assignment represent unsigned integers. - All amounts to left shift or to right shift will be inputted as an argument that represents a base-10 integer greater than or equal to zero. Also, all amounts to left shift or to right shift will be inputted as an argument that represents a base-10 integer less than or equal to the value of the bit string argument represented in base-10. Before you write any code for this assignment, you should work through all examples with paper and pencil. Examples Your C source code should be in a file called lab04. c, and it should be compiled into an executable called lab04.out. Your C program must look exactly like the examples below when run on the command line on odin, it must compile correctly, and it must run correctly with any valid sequence of inputs provided as command line arguments. You may assume that the command line arguments will be entered in a correct manner as demonstrated by the examples. Each example is a separate execution of a correct program for this assignment. ./lab04.out -not 011 r011 evaluates to 100 using bit strings of length 3 -3 evaluates to 4 using unsigned 3-bit integers ./lab04.out -not 1010110001 -1010110001 evaluates to 0101001110 using bit strings of length 10 - 689 evaluates to 334 using unsigned 10-bit integers

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Identify the elements that make up the employee reward package.

Answered: 1 week ago

Question

Understand the purpose, value and drawbacks of the interview.

Answered: 1 week ago