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.
voidcalculate_the_maximum(intn,intk){//Write your code here.intmax_and=0,max_or=0,max_xor=0,and,or,xor,i,j;for(i=1;i<n;i++){for(j=i+1;j<=n;j++){and=i&j;or=i|j;xor=i^j;if((and>max_and)&&(and<k))max_and=and;if((or>max_or)&&(or<k))max_or=or;if((xor>max_xor)&&(xor<k))max_xor=xor;}}printf("%d\n%d\n%d",max_and,max_or,max_xor);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →