![Programming in C](https://www.bartleby.com/isbn_cover_images/9780321776419/9780321776419_largeCoverImage.gif)
Write a function called b to extract a specified set of bits. Have it take three arguments: the first an u , the second an integer starting bit number, and the third a bit count. Using the convention that bit numbering starts at 0 with the leftmost bit, extract the specified number of bits from the first argument and return the result. So the call
b
extracts the three leftmost bits from x. The call
b
extracts five bits starting with the fourth bit in from the left.
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 11 Solutions
Programming in C
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Software Engineering (10th Edition)
Modern Database Management
Experiencing MIS
Starting Out with Programming Logic and Design (4th Edition)
- In Python write a function decoding() that takes an encoded string and an integer as the parameters, and returns the original string. The encoding was performed as follows. First, the original string is reversed. Then, each character in the new string is replaced by the character that is a given number of positions away in the ASCII character encoding table. For example, the following call to yur function : encoding('ABCabc', -10) should return the encoded string 'YXW987'.arrow_forwardDefining a binary number as Program 1, write the function int binToDec(const int bin[]) to convert an eight-bit unsigned binary number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input. Defining bAnd, bin1, and bin2 as binary numbers as in Program 1 above, write the void function void binaryAnd(int bAnd[], const int bin1[], const int bin2[]) to compute bAnd as the logical AND of the two binary numbers bin1 and bin2. Do not output the binary number in the function. Test your function with interactive input. Program1 in C: #include <stdio.h>int main(){int binNum[8]; // Array to read binary numberlong dec=0,n=0; // variables used to convert binary to decimalint k=0,l=0;long binary=0;int i=1,j=0,remainder=0; //reading the binary number in to the array binNumprintf("Please Enter the first binary number with each bit seperate by at least one space : \n"); scanf("%d %d %d %d %d %d %d…arrow_forwardIn Python, write a function named cipher that takes a string. The function returns that string in a ciphered form by using the ord of the first letter of the string to cipher each letter including the first letter. Hence for abc, use the ord of 'a', and add it to the ord of 'a' and convert that result to a character use the chr function. This character should be concatenated to the same action on the letter b and so on. Hence the function returns: chr(ord('a')+ord('a')) + chr(ord('a')+ord('b')) + chr(ord('a')+ord('c')).Obviously you need a loop to iterate on each letter. Write another function to decipher (do the opposite of the previous function), given a string and returns the deciphered string. Obviously, the first letter's ord is halved to find the first letter, and that value is used to decipher the remaining letters. From main, write code to get a string, as input, then call the cipher function and print its output.Then call the decipher function and display its output. The…arrow_forward
- Write a function that takes the number n, which reverses the binary representation of that number, and then returns the new number from the returned binary. Examples BinaryInteger (10) - 5 // 10 = 1010 -> 0101 = 5 BinaryInteger (12) → 3 // 12 = 1100 -> 0011 = 3 BinaryInteger (25) → 19 // 25 = 11001 -> 10011 = 19 BinaryInteger (45) → 45 // 45 = 101101 -> 101101 = 45arrow_forwardCreate a function that takes a single Hexadecimal number as an argument and returns the equivalent six-digit binary number to light the display. Consider the six-digit binary number as an incoming input from a serial port. The segment display is a common cathode segment display that means you need to give a logical 1 to light up each segment. a b C d e g dp- Examples e f d dp toDisplay (0x1) → 0x06 // [dp, g, f, e, d, c, b, a] toDisplay (0x8) → 0x7F // [dp, g, f, e, d, c, b, a] toDisplay (0x0) → 0x3F // [dp, g, f, e, d, c, b, a] = = = Correct Method common www.petervis.com [0, 0, 0, 0, 0, 1, 1, 0] [0, 1, 1, 1, 1, 1, 1, 1] [0, 0, 1, 1, 1, 1, 1, 1]arrow_forwardwe will pretend that bits are sent as strings (theyare not; this would be terribly inefficient). Write a function evenParity(bits) that returns True if the string bits haseven parity and False otherwise. For example, evenParity('110101')should return True and evenParity('110001') should return Falsearrow_forward
- Write a function that keeps computing the sum of the digits of x^n, until there is only one digit left. For example, sumOfDigits(2,5) returns 5, because 2 ^ 5 = 32 = 3 + 2 = 5 Another example, sumOfDigits(2,8) returns 4, because 2 ^ 8 = 128 = 1 + 2 + 8 = 13 = 1 + 3 = 4arrow_forward***python python *** Write a function encoding() that takes a string and an integer as the parameters, and returns an encoded string.The encoding is performed as follows. First, the given string is splited into two sub-strings, where characters at even poisitions is in one sub-string, characters at odd positions are inthe second sub-string. The two sub-strings are then put together, even character string first. Then, each character c is replaced by the character c' that is located the given integernumber of positions away from c in the ASCII character encoding table. For example: encoding('ABCabc' ,-10) should return the new string '79X8WY'.arrow_forwardD. Implement a function that finds the last check digit using congruence; 3x₁ + 7x2 + 2x3 + x4 + 3x5 + x6 + 3x7 + xg + 5x9 + x10 + 3x11 + x12 = 0(mod10) given the first 11 digits stored in a string as input, eg: ¹99284792783'. (Do not use predefined functions or operators that perform this specific task) use "79357343104", "34553463334" and "66340534853" to test your function..arrow_forward
- I need help to write a function that: 1. Take two parameters, a nucleotide sequence as a string, and an integer. 2. Check for invalid characters (not ATCG). If invalid character is found, exit function 3. Make the entire string lower case 4. For X iterations, where x is the integer parameter - Choose a character position in the string at random - Determine which nucleotide is at that position. At random, select a different nucleotide and replace the previous nucleotide with the new one. Use String splicing, or list() and "".join() -The new nucleotide should be uppercase so that the substitution is clear and obvious. 5. Test your code to make sure this behavior works as intended. Keep the number of iterations low, and add in a reporting mechanism that makes it clear what is happening (what position was chosen, what new nucleotide was chosen, etc). Comment out this out once you're sure the function works as it should. 6. Return the new string Python Programmingarrow_forwardWe can assign a value to each character in a word, based on their position in the alphabet (a = 1, b = 2, ..., z = 26). A balanced word is one where the sum of values on the left-hand side of the word equals the sum of values on the right-hand side. For odd length words, the middle character (balance point) is ignored. Write a function that returns true if the word is balanced, and false if it's not. Examples balanced ("zips") → true // "zips" = "zi|ps" = 26+9|16+19 = 35|35 = true balanced ("brake") // "brake" = "br|ke" false = 2+18 | 11+5 = 20 16 = falsearrow_forward''''arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
![Text book image](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)