(Computer architecture: bit-level operations) A short value is stored in 16 bits. Write a
Enter an integer: 5
The bits are 0000000000000101
Enter an integer: −5
The bits are 1111111111111O11
(Hint: You need to use the bitwise right shift operator (≫) and the bitwise AND operator(&), which are covered in Appendix G, Bitwise Operations.)
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Absolute Java (6th Edition)
Computer Science: An Overview (12th Edition)
Concepts of Programming Languages (11th Edition)
C Programming Language
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Problem Solving with C++ (9th Edition)
- (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forwardFind the error in the codearrow_forwardA- write a program that multiply a number in Ax by 19B- write a program that divides the number in BL by the number in CL then multiplies the result by 2arrow_forward
- If you attempt to add a double, a short, and a byte, the result will be a(n)arrow_forward(IN C LANGUAGE) Cumulative Addition: Computer selects a number between 7 and 23 at random. User will only add 2, 3 or 5 numbers to reach that number. For example: To reach 14:User will enter 5 5 2 2 (4 input).Also he can enter 2 2 2 2 2 2 2 (7 input) or 3 3 3 3 2 (5 input)arrow_forwardIf you try to add a double, a short, and a byte, you will get a (n)arrow_forward
- Using C programming language C) Write a program that adds together RO and R1, and then if the sum is odd set R3 to all ones (0XFF), otherwise set it to all zeros (0x00) (Hint - if you're confused, search online for "bit masking") 4.arrow_forwardCompute the following expression: var4 = (var1+var4) / (var2*var3) All the variables are 32-bit long signed numbers. Translate the following expression into assembly code (MASM). You can only use single operand IMUL and IDIV along with MOV, ADD, SUB.arrow_forward(PYTHON) A Krishnamurthy number is a number which sum of the factorial of its digits is equal to the number itself. For example: Let us consider the number 145. Factorial sum = 1! + 4! + 5! = 1 + 24 + 120 = 145. Therefore 145 is a Krishnamurthy number. Other examples include: 1, 2, 40585. Write a program that does the following: • asks the user to input an integer. • computes whether the number is a Krishnamurthy number. • then finally prints the result. Note: You are not allowed to use the built-in function math.factorial.arrow_forward
- using emo8086, display a set of "*"or * base on the user's integers input (0-9) example: enter a number:6 *****arrow_forward1. Here is a program that simply reads characters from the keyboard until the user hits the enter (or return) key. Add code to the program so that it allows the user to enter up to a 32-bit integer in hexadecimal and converts the number to int format. Your algorithm should make use of the masking operation described above. The program should display the int in both hexadecimal and decimal format for the user. Assume that the user will not make mistakes. /* readHex.c * Asks user to enter a number in hexadecimal. * INCOMPLETE PROGRAM FOR EXERCISE. * 2017-09-29: Bob Plantz $/ #include #include int main(void) { int x; unsigned char aChar; printf("Enter an integer in hexadecimal: "); fflush(stdout); x = 0; read (STDIN_FILENO, &aChar, 1); while (aChar != '\n') { read (STDIN_FILENO, &aChar, 1); } // initialize result // get first character. // look for return key printf("You entered %#010x = %d (decimal)\n\n", x, x); return 0;arrow_forward(Count positive and negative numbers and compute the average of numbers) Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the maximum, minimum, and average as a floating-point number. Here is a sample run:Enter an integer, the input ends if it is 0: 1 2 -1 3 0The number of positives is 3The number of negatives is 1The maximum is 3.0The minimum is -1.0The average is 1.25arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning