Menu

Need Help 2 Question Using Unix Operator Used Quickly Check Number Odd Even Value Expressi Q43893413

I need help with these 2 question using UNIX

  1. The & operator can be used to quickly check if anumber is odd or even. The value of expression (x & 1)would be non-zero only if x is odd, otherwise the value would bezero.

#include <stdio.h>

int main()

{

   //User enters an integer number

// if x is even, print “even”, otherwise print “odd” using &operator

    return 0;

}

        Complete the aboveprogram and test it with 17, 19, 22, 100.

        Your output :

3.

Suppose two integer values a and b
Perform,
x = a ^ b
Now x ^ b will evaluateto a
and
x ^ a will evaluate tob.

The following program is to swap two numbers using xoroperator.

/**

* C program to swap two numbers using bitwise operator

*/

#include <stdio.h>

int main()

{

    int num1, num2;

    /* Input two numbers from user */

    printf(“Enter any two numbers: “);

    scanf(“%d%d”, &num1, &num2);

    printf(“Original value of num1 = %dn”,num1);

    printf(“Original value of num2 = %dn”,num2);

    /* Swap two numbers */

    //Fill out the codes using xor operator

    printf(“Num1 after swapping = %dn”,num1);

    printf(“Num2 after swapping = %dn”,num2);

    return 0;

}

Output with test case: 66, 22

Expert Answer


Answer to I need help with these 2 question using UNIX The & operator can be used to quickly check if a number is odd or even. The…

OR