We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>//Complete the following function.voidcalculate_the_maximum(intn,intk){//Write your code here.inti,j,v,x,y,m=0;intand[50],or[50],xor[50];intp,q,r;for(i=1;i<n;i++){for(j=i+1;j<=n;j++){v=(i&j);if(v<k){and[m]=v;}x=(i|j);if(x<k){or[m]=x;}y=(i^j);if(y<k){xor[m]=y;}m++;}}p=0;for(i=0;i<sizeof(and)/sizeof(int);i++){if(and[i]>p){p=and[i];}}q=0;for(i=0;i<sizeof(or)/sizeof(int);i++){if(or[i]>q){q=or[i];}}r=0;for(i=0;i<sizeof(xor)/sizeof(int);i++){if(xor[i]>r){r=xor[i];}}printf("%d\n %d\n %d\n",p,q,r);}intmain(){intn,k;scanf("%d %d",&n,&k);calculate_the_maximum(n,k);return0;}
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →
Can you tell me where is the mistake