Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Bitwise Operator

Home > Programs > Bitwise Operator

13 / 15

Write an efficient program to set the bits in a given range(start and end position given) in an integer number

Answer:

import java.util.*;
import java.lang.*;
import java.io.*;

class SetBits
{
    public
      int start;
      int end;
      int num;


public
 SetBits(int s, int e, int n)
 {
     start = s;
    end = e;
    num = n;
 }

  void set()
  {
    for (int i = start; i

Asked In ::

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: