You are given the task of writing a procedure int_size_is_32() that yields 1 when run on a machine for which an into is 32 bits and yields 0 otherwise. You are not allowed to use the size of operator. Here is a first attempt:
When compiled and run on a 32-bit SUN SPARC, however, this procedure returns 0. The following compiler message gives us an indication of the problem:
Warning: left shift count >= width of type
- A. In what way does our code fail to comply with the C standard?
- B. Modify the code to run properly on any machine for which data type int is at least 32 bits.
- C. Modify the code to run properly on any machine for which data type int is at least 16 bits.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Introduction to Programming Using Visual Basic (10th Edition)
Database Concepts (8th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Starting out with Visual C# (4th Edition)
Database Concepts (7th Edition)
- Please use C++ In this lab, you need to write a program which, given a seven digit binary input given below, it will check to see if there is a single bit error using the Hamming Code method discussed in lab. For a sample of Hamming Code, the input: 1110101 will reveal that ‘110’ is the location of the error (meaning the sixth slot in the input), so the corrected number would be 1010101, and the actual message transmitted, would be 1011, which is 11 in decimal. You can use this example to test your program to ensure it’s working correctly. Create a program which can, given a 7-bit long input, written in Hamming Code style, do the three following tasks, displaying the results as output. (1) Determine if there’s an incorrect bit, and if so, where it is. (2) Display what the CORRECT code should look like (if it needs to be corrected.) (3) Display the decimal form of the message that was sent, after any needed correction. Remember, when using Hamming…arrow_forwardPlease write comments in your code and show output You are required to write the following problem using recursion and backtracking.Write the program in: MIPS Assembly using MARS simulator. 3 You are required to write a program that identifies all prime numbers. Your program should receive 2 input integers. The first input is an upper bound value that your program should identify all prime numbers smaller than it. The second integer is the number of 1s in the binary representation of the prime numbers that your program should print as an output. In other words, if your program receives as an input n and y, your program should identify all prime numbers between 0 and n, and print only those prime numbers whose binary representation contains a number of 1s exactly equals to y. You are required to solve this problem using the Sieve bitwise algorithm. The idea behind the Sieve algorithm is to exclude all the even numbers bigger than 2 as they are definitely not prime numbers. If your upper…arrow_forwardIn JAVA code (Insertion Sort): 1. Prepare a data set containing 10,000 integers (random). 2. Make a code that will create 3 variants of the data: one in best case (data are arranged in ascending order); the other in worst case (data are arranged in descending order); and the last in average case (data are randomly arranged). 3. Each integer is considered as one input in the code. 4. The output of your program should be the number of statements executed in the process of sorting for each of the algorithms. This, therefore, means that you have to embed a counter variable in your program that keeps track of the number of statements executed in the sorting part of your code. 5. The end value of the variable shall be the output of your program.arrow_forward
- Securing data is very important. We are developing an encryption module for the communication system in C++. You are supposed to input data in a character array of size 100. After taking input in array pass this array to a function to encrypt. This function applies following encryption on data. For testing purposes, after encryption function is called, the main function should print the encrypted data in the array. Convert upper case letters to lower case and lower case letters to upper case. After conversion replace each alphabet with its next alphabet, for example “A” will be replaced by “B”, “B” will be replaced by “C”, and so on. Similarly “a” will be replaced by “b” etc. However, “Z” should be replaced by “A” and “z” should be replaced by “a”. Digits must be replaced by subtracting it from 9 for example 0 should be replaced by 9 (9-0=9), 1 should be replaced by 8 (9-1=8), 2 should be replaced by 7 (9-2=7)………… and 9 should be replaced by 0 (9-9=0). Spaces should be replaced by $…arrow_forwardIn c++, please. Thank you! Given a main() that reads user IDs (until -1), complete the BubbleSort() functions to sort the IDs in ascending order using the Bubblesort algorithm, and output the sorted IDs one per line. You may assume there will be no more than 100 user IDs. Ex. If the input is: kaylasimms julia myron1994 kaylajones -1 the output is: julia kaylajones kaylasimms myron1994 The following code is given: #include <string>#include <iostream> using namespace std; // TODO: Write the Bubblesort algorithm that sorts the array of string, with k elementsvoid Bubblesort(string userIDs [ ], int k) { } int main() { string userIDList[100]; string userID; cin >> userID; while (userID != "-1") { //put userID in the array cin >> userID; } // Initial call to quicksort Bubblesort(userIDList, /* ?? */ ); //make this output only the userIDs that were entered, not garbage for (int i = 0; i < 100; ++i) { cout <<…arrow_forwardIn JAVA code (Insertion Sort): 1. Prepare a data set containing 10,000 integers (random). 2. Make a code that will create 3 variants of the data: one in best case (data are arranged in ascending order); the other in worst case (data are arranged in descending order); and the last in average case (data are randomly arranged). 3. Each integer is considered as one input in the code. 4. The output of your program should be the number of statements executed in the process of sorting for each of the algorithms. This, therefore, means that you have to embed a counter variable in your program that keeps track of the number of statements executed in the sorting part of your code. 5. The end value of the variable shall be the output of your program. Below is a sample of the code in Bubble Sort; I am asking for the program for insertion sort.arrow_forward
- Use the C programming language to write code that proclaims and sets a double, int, and char. Afterward, proclaim and set a pointer to the double, int, and char. The code must print the inscription of, and value stored in, and the memory size (in bytes) of all six variables. The "0x%x" formatting specifier outputs inscriptions in hexadecimal. The "%f" outputs floating values. The sizeof operator must determine the memory size allocated for all variables. SAMPLE OUTPUT: Char ___ 's inscription is 0x___Int ___'s inscription is 0x___Double ___'s inscription is 0x___Char* ___'s inscription is 0x___Int* ___'s inscription is 0x___Double* ___'s inscription is 0x___Char ___ 's value is ___Int ___'s value is ___Double ___'s value is ___Char* ___'s value is 0x___Int* ___'s value is 0x___Double* ___'s value is 0x___Char ___ 's size is ___ bytesInt ___'s size is ___ bytesDouble ___'s size is ___ bytesChar* ___'s size is ___ bytesInt* ___'s size is ___ bytesDouble* ___'s size is ___ bytesarrow_forwardQUESTION One of the downsides of using expressions that produce results other than true or false is it is expensive to type-check it hurts readability since it may be confusion to know which route an execution will take. it can cause side effects skewing the results of the rest of the code it hurts writability since we have to write such long expressions.arrow_forwardin javascript please create a function that does the following and is named as such please don't copy and paste the incorrect answer sequence( start, step ) This function takes two numeric inputs, start and step, and returns a function of no inputs. The ith invocation of the resulting function will generate the value: start + step * i. The first invocation is said to be the 0th. Examples var x = sequence( 3, 15 ) [ x(), x(), x() ] => [ 3, 18, 33 ] var y = sequence( 28, -5 ) [ y(), y(), y() ] => [ 28, 23, 18 ]arrow_forward
- write a c++ program that asks user to enter a number and then print the number that is maximum time repeated in that number and count how mnay times its repeated. remember that if two numbers are repeated same times then you need to output both of them and total times they are repeated. Do this only using loops and functions. arrays pointers are not allowed. for example:input:122344, digit = 2,frequency=2 digit= 4, frequency = 2arrow_forwardWrite a C++ program to find the area and perimeter of a rectangle. area= length*width; perimeter=2(length+width); Note: This program should use pointers (new). You have to de-allocate the memory using delete operator. Check your program that it should not have memory leaks or bad memory/cheap memory. Use valgrind to check the memory leaks. See the commands below for compiling and executing your code.arrow_forwardWrite a python program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order.def swap_values(user_val1, user_val2) I can get the first input to reverse but the subsequent outputs I am struggling to make work.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education