Search Results For: Bitwise
C programming code to swap using bitwise XOR
C programming code to swap using bitwise XOR
1 |
#include <stdio.h>int main(){int x, y;scanf("%d%d", &x, &y);printf("x = %d\ny = %d\n", x, y);x = x ^ y;y = x ^ y;x = x ^ y;printf("x = %d\ny = %d\n", x, y);return 0;}</stdio.h> |
C program to check Odd or Even without using bitwise or modulus operator
C program to check Odd or Even without using bitwise or modulus operator
1 |
#include <stdio.h>int main(){int n;printf("Enter an integer\n");scanf("%d", &n);if ((n/2)*2 == n)printf("Even\n");elseprintf("Odd\n");return 0;}</stdio.h> |
C program to find Odd or Even using bitwise operator
C program to find Odd or Even using bitwise operator
1 |
#include <stdio.h>int main(){int n;printf("Input an integer\n");scanf("%d", &n);if (n & 1 == 1)printf("Odd\n");elseprintf("Even\n");return 0;}</stdio.h> |
Bitwise Operations using C++
Bit-wise Operations utilizing C++
1 |
#embrace<br/>#embrace<br/>#embrace void dectobi(int p)<br/>{<br/>int b,i,x,d;<br/>for(i=31;i>=0;i--)<br/>{<br/>d=1<<i;<br/>b=p&d;<br/>if(b==0)<br/>printf("0");<br/>else<br/>printf("1");<br/>}<br/>} <br/><br/>void essential()<br/>{<br/><br/>int i,j,okay,ch,n,m,a;<br/>char cho;<br/>clrscr();<br/>do<br/>{<br/>printf("enter a integern");<br/>scanf("%d",&n);<br/>dectobi(n);<br/>printf("n 1 for 1`s praise");<br/>printf("n 2 for AND opertion");<br/>printf("n 3 for OR opertion");<br/>printf("n 4 for EX-OR opertion");<br/>printf("n 5 for LEFT SHIFT opertion");<br/>printf("n 6 for RIGHT SHIFT opertion");<br/>printf("n 7 for EXITn");<br/>scanf("%d",&ch);<br/>swap(ch)<br/>m;<br/>dectobi(a);<br/>break;<br/>case 4:<br/>printf("enter intgern");<br/>scanf("%d",&m);<br/>dectobi(m);<br/>printf("after EX-ORn");<br/>a=n^m ;<br/>dectobi(a);<br/>break;<br/>case 5:<br/>printf("enter the no by u need to LEFT SHIFT");<br/>scanf("%d",&m);<br/>a=n<<m;<br/>printf("after LEFT SHIFTn");<br/>a=n<<1;<br/><!--1--> dectobi(a);<br/>break;<br/>case 6:<br/>printf("enter the no by u need to RIGHT SHIFT");<br/>scanf("%d",&m);<br/>a=n>>m;<br/>printf("after RIGHT SHIFTn");<br/>dectobi(a);<br/>break;<br/>case 7:<br/>exit(0);<br/><br/>flushall();<br/>printf("nwant to proceed (y/n)");<br/>scanf("%c",&cho);<br/>}<br/>whereas(cho!='n');<br/><br/>}<br/> |
Supply projectgeek.com
- 1
- 2