Program to Parity Check of a Number.
Parity Check of a Number Program Using C++.
Program:
- C++
- C
- Java
- Python
- C#
- PHP
- Javascript
Output
Enter a number: 7
Parity of 7 is Even
Program to Parity Check of a Number.
Parity Check of a Number Program Using C++.
Program:
/*----------------------------------------------------------------------------------------- Simulate Even Parity generator and checker Program Using C++ -----------------------------------------------------------------------------------------*/ #include <iostream> using namespace std; bool parityFind(int n) { int count = 0; int temp = n; while (temp>=2) { if(temp & 1) count++; temp = temp >> 1; } return (count % 2)?true:false; } int main() { int n; cout << "Enter a number: "; cin >>n; cout << "Parity of " << n << " is " << (parityFind(n)?"Odd":"Even"); } |
Enter a number: 7
Parity of 7 is Even
We can use the package Pytube to download YouTube videos in a Python script. It’s a free tool you can install from the PyPI repository....