All submissions

Extract the Nibble from an 8-bit Register

Code

#include <stdio.h>


int nibble(int num, int pos){
    

if(pos==0){
return num & 0X0F ;

}
else{
return (num>>4) & 0X0F ;
}
}


int main (){

    int num;
    int pos;
   
    scanf("%d",&num);
    scanf("%d", &pos);

    printf("%d",nibble(num,pos));
    return 0;
}

Solving Approach

 

 

 

Loading...

Input

170 0

Expected Output

10