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