//========================
//Program in C to set nth bit, bitset.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 set:\n");
scanf("%d%d",&number,&bits);
printf("\n You Entered: %d and %d \n",number,bits);
showbits(number);
number=number^(1<<(bits-1));
printf("\n Number now is: %d \n",number);
showbits(number);
printf("\n");
return 0;
}
//Program in C to set nth bit, bitset.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 set:\n");
scanf("%d%d",&number,&bits);
printf("\n You Entered: %d and %d \n",number,bits);
showbits(number);
number=number^(1<<(bits-1));
printf("\n Number now is: %d \n",number);
showbits(number);
printf("\n");
return 0;
}
Program in CPP/C++ to set nth bit, bitset.c
ReplyDeleteProgram in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
DeleteProgram in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
ReplyDeleteProgram in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c
ReplyDeleteProgram in CPP/C++ to set nth bit, bitset.c
Program in CPP/C++ to set nth bit, bitset.c Program in CPP/C++ to set nth bit, bitset.c