In this part, you have to determine the parity of a number and the number of 1-bit pairs present in the number. Parity refers to whether a number contains an even or odd number of 1-bits. 1-bit pairs are defined by two adjacent 1’s without overlap with other pairs. Input format: This program takes a single number as an argument from the command line. This number should be considered as an unsigned short. Output format: Your program should print either “Even-Parity” if the input has an even number of 1 bits and “Odd-Parity” otherwise, followed by a tab. Your program should then print the number of 1-bit pairs present in the number followed by a new line character. Example Execution: $ ./second 12 Even-Parity 1 $ ./second 31 Odd-Parity 2 For example: Number Binary sequence Parity Number of pairs 7 111 Odd 1 15 1111 Even 2 367 101101111 Odd 3
CODE:
#include<iostream>
using namespace std;
int main()
{
unsigned short int n;
cin>>n;
int bin[16];
for(int i=15;i>=0;i--)
{
bin[i]=n%2;
n=n/2;
}
string binary="";
int i;
for(i=0;i<16;i++)
{
if(bin[i]==1)
break;
}
for(int j=i;j<16;j++)
binary+=char(bin[j]+48);
int ones=0;
for(int j=0;j<16;j++)
{
if(bin[j]==1)
ones++;
}
string parity;
if(ones%2==0)
parity="Even";
else
parity="Odd";
int pairs=0;
for(int j=0;j<15;j++)
{
if(bin[j]==1&&bin[j+1]==1)
{
pairs++;
j++;
}
}
cout<<"Number Binary sequence Parity Number of
Pairs"<<endl;
cout<<n<<"\t"<<binary<<"\t"<<parity<<"\t"<<pairs<<endl;
return 0;
}

In this part, you have to determine the parity of a number and the number of...
For this problem, you have to use following hash function: key
modulo the number of buckets.
Input format: This program takes a file name as
argument from the command line. The file is either blank or
contains successive lines of input. Each line contains a character,
either ‘i’ or ‘s’, followed by a tab and then an integer, the same
format as in the Second Part. For each of the lines that starts
with ‘i’, your program should insert that...
Extra problem: Use the attached sheet to draw a 8- bit odd parity generator and a odd-parity checker for the 8 data bits and odd parity bit. Let the Error output be active-low (so that it goes low if there is an error and is high if there is no error) Parity Error-Detection System Using 74280s, design a complete parity generator/checking system. It is to be used in an 8-bit, even-parity computer configuration. Solution: Parity generator: Because the 74280 has...
Done in Java using Apache NetBeans IDE 11.2 -- Objectives: To create a data structure with underlying linked chain; To utilize and implement code dealing with parity big codes for error detection; To read data from file **The other answer when searching for this question does not have a ParityChain class, a ParityChainDemo class or even include some of the stated requirements (such as hasError method). **Parity bit was specified by instructor to be LEFT most bit in chain In...
**I asked this question once, and the answer completely ignored a majority of the rules listed on this. PLEASE read what is necessary before giving an answer. **NEITHER answer when searching for this question has a ParityChain class, a ParityChainDemo class or even include some of the stated requirements (such as hasError method). **Parity bit was specified by instructor to be LEFT most bit in chain Done in Java using Apache NetBeans IDE 11.2 -- Objectives: To create a data...
****************IN C PROGRAMMING**************** Sometimes even the smallest change in data can make a big difference. Luckily, there are algorithms that will let us not only detect when there has been an error(like checksums), but also correct when an error has occurred. These algorithms are called error-correcting codes.There are many examples of error correcting codes but one of the simplest examples is called a parity bit. A parity bit is just a single bit (1 or 0) that indicates whether a...
(Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned intvariable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator....
Draw an automaton which will accept all integers (in binary form) of Odd parity (number of 1’s in the string is odd). Now write a code in a high level language (C++) for the automaton. Take inputs of two strings, one of odd parity (e.g, 00111011) and another one of even parity (e.g., 1100110011). Your code should accept the right string and reject the wrong one. Print your code and results
# Write PYTHON programs that read a sequence of integer inputs and print # a. The smallest and largest of the inputs. # b. The number of even and odd inputs. # c. Cumulative totals. For example, if the input is 1 7 2 9, the program should print # 1 8 10 19. # d. All adjacent duplicates. For example, if the input is 1 3 3 4 5 5 6 6 6 2, the # program should print...
C programming lab: Description: In this lab you will write a program that will contain two functions, setlsbs() and getlsbs(). These functions will use bitwise operators to embed and extract "hidden" bits in a character array. Write a program to test your functions as follows: Obtain a random number seed from the command line of your program using command line arguments. Initialize an array p of 8 unsigned char with random numbers from 0 to 255 Initialize a separate unsigned...
Edit, compile, and run the following programs on the UNIX shell: Write a program that takes in six commandline arguments and has four functions (described below) that use bitwise operators. The user should enter six space-separated commandline arguments: four characters (any ASCII character) followed by two integers. Anything else should print an error message telling the user what the correct input is and end the program. Convert the commandline input into "unsigned char" and "unsigned int" datatypes. Be careful with...