//========================
//Program in C to check bit at nth position, bitcheckatn.c
//========================
#include<stdio.h>
int showbits(int nn)
{
unsigned int m;
m=1<<(sizeof(nn)*8-1);
while(m > 0)
{
if(nn & m)
{
printf("1");
}
else
{
printf("0");
}
m>>=1;
}
}
int main()
{
int number,bits;
printf("Enter a nomber and bits to see qt bit th position:\n");
scanf("%d%d",&number,&bits);
printf("\n You Entered: %d and %d \n",number,bits);
showbits(number);
number=number&(1<<(bits));
printf("\n Now number is :%d and \n bit at %d position is: \n",number,bits);
showbits(number);
printf("\n");
return 0;
}
//Program in C to check bit at nth position, bitcheckatn.c
//========================
#include<stdio.h>
int showbits(int nn)
{
unsigned int m;
m=1<<(sizeof(nn)*8-1);
while(m > 0)
{
if(nn & m)
{
printf("1");
}
else
{
printf("0");
}
m>>=1;
}
}
int main()
{
int number,bits;
printf("Enter a nomber and bits to see qt bit th position:\n");
scanf("%d%d",&number,&bits);
printf("\n You Entered: %d and %d \n",number,bits);
showbits(number);
number=number&(1<<(bits));
printf("\n Now number is :%d and \n bit at %d position is: \n",number,bits);
showbits(number);
printf("\n");
return 0;
}
Program in C++/Cpp/C to check bit at nth position, bit_checkatn.c
ReplyDeleteProgram in C++/Cpp/C to check bit at nth position, bit_checkatn.c
Program in C++/Cpp/C to check bit at nth position, bit_checkatn.c
Program in C++/Cpp/C to check bit at nth position, bit_checkatn.c
Program in C++/Cpp/C to check bit at nth position, bit_checkatn.cProgram in C++/Cpp/C to check bit at nth position, bit_checkatn.c
Program in C++/Cpp/C to check bit at nth position, bit_checkatn.c
Program in C++/Cpp/C to check bit at nth position, bit_checkatn.c