#include <stdio.h>

void printHex(int hex, int no){
    for(int i=no-1; i>=0; i--){
        printf("%x",(hex>>4*i)&0xF);
    }
    printf("\n");
}

int main() {
    int a = 0xA301;
    int b = a;
    int count = 0;
    int pos = 0;

    while(a!=0){
        count++;
        if((a&0xF)==0x3){ //or 0xA
            pos = count;
        }
        a=a>>4;
    }
    printf("%d %d\n",count, pos);
    printHex(b, count);
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: