any logic to small the code ???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

any logic to small the code ????

//-----write a function of increment by bitwise opretor //-----suggest me the simple logic for that #include<stdio.h> int plus(int,int); int main() { int M,P,i,mask=1; printf("enter the number\n"); scanf("%d",&i); P=plus(i,mask); printf(" number = %d , plus = %d\n",i,P); return 0; } int plus(int num,int mask) { int j=0; if((num&mask)==0) return num=num|mask; else { while((num&mask)!=0) { mask<<=1; ++j; } if((num&mask)==0) num=num|mask; num=num>>j; num=num<<j; return num; } }

12th Jun 2020, 10:05 PM
Ashutosh k.
Ashutosh k. - avatar
0 Answers