# Computer Science Fundamentals

##### Description

159.102 Computer Science Fundamentals Assignment 2

You have been asked to write a C program that acts as a simple calculator.

The program prompts the user to type in an expression.

The user then types in: number1 (in hexadecimal) an instruction (2 or 3 characters) number2 (in hexadecimal).

There will be a single space before and after the instruction. The input will be correct. No verification is necessary.

All input numbers will be within the range 0x00 to 0xffffffff.

Use the type unsigned int for your numbers.

Use the %x format specifier to input and print hexadecimal values.

The instruction can be one of the following:

sub subtract number2 from number1

and bitwise and of the two numbers

or bitwise or of the two numbers

xor bitwise exclusive or of the two numbers

shl shift the bits of number1, number2 places to the left

shr shift the bits of number1, number2 places to the right

asr arithmetic shift right the bits of number1, number2 places to the right (see below)

rol rotate the bits of number1, number2 places to the left (see below)

ror rotate the bits of number1, number2 places to the right

A one-bit arithmetic shift right, shifts each bit in the number one place to the right.

If the most significant bit of the original number is a 1,the most significant bit of the answer is set to 1, otherwise it is set to 0.

A one-bit rotation left shifts all the bits one place to the left, the most significant bit of the original number becomes the least

A one-bit rotation right shifts all the bits one place to the right, the least significant bit of the original number becomes the

most significant bit of the answer.

Be careful using the C operators &gt;&gt; and &lt;&lt;. (m &gt;&gt; n) is &#39;undefined&#39; if n is greater than 31 10 .

(i.e. the answer could be a random value!, but is more likely to be (m &gt;&gt; n&amp;0x1f))

Your program must work with any value of n. (Shift by 1 in a loop n times).

Examples:

Type in an expression: 49 add 41

Type in an expression: 49 sub 41

Type in an expression: 2a xor 7d

Type in an expression: 49 ror 10

Type in an expression: 80000002 asr 1

Marks will be awarded on how many test cases your program handles correctly.

Test your program with different numerical values and instructions before submission.

## Calculate the price of your order

#### Simple Order Process

Fill in the Order Form

Share all the assignment information. Including the instructions, provided reading materials, grading rubric, number of pages, the required formatting, deadline, and your academic level. Provide any information and announcements shared by the professor. Choose your preferred writer if you have one.

Once we receive your order form, we will select the best writer from our pool of experts to fit your assignment.

Share More Data if Needed

Let Our Essay Writer Do Their Job

Once you entrust us with your academic task, our skilled writers embark on creating your paper entirely from the ground up. Through rigorous research and unwavering commitment to your guidelines, our experts meticulously craft every aspect of your paper. Our process ensures that your essay is not only original but also aligned with your specific requirements, making certain that the final piece surpasses your expectations.

Upon the completion of your paper, it undergoes a meticulous review by our dedicated Quality and Proofreading department. This crucial step ensures not only the originality of the content but also its alignment with the highest academic standards. Our seasoned experts conduct thorough checks, meticulously examining every facet of your paper, including grammar, structure, coherence, and proper citation. This comprehensive review process guarantees that the final product you receive not only meets our stringent quality benchmarks but also reflects your dedication to academic excellence.