Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer the question accordingly and show appropriate result on screen. Wr

ID: 3871077 • Letter: P

Question

Please answer the question accordingly and show appropriate result on screen. Write the code in C programming

Determine whether a bit is set Write a function that accepts as input an unsigned char, and an integer bitNum (range 0-7) and using the “shift” and “and” operators returns a 1 if bit bitNum is set (bit bitNum is 1) and 0 otherwise.   For example, if the bit sequence of a char is 00010100 and bitNum == 4 then the answer should return 1.   unsigned char isBitSet(unsigned char c, int bitNum);

Explanation / Answer

#include <stdio.h>
#include<conio.h>

void main()

{

    unsigned int num;

    int result, pos;

    printf("Please enter the unsigned integer: ");

    scanf("%d", &num);

    printf("Please enter the position to be searched ");

    scanf("%d", &pos);

    result = (num >> (pos));

    if (result & 1)

        printf("the bit is set ");

    else

        printf("the bit is reset ");
getch();

}