Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Ques--Input a number and then find the next higher number
such that for both the number (inputted and the next higher
number)
in binary representation contains equal number os ones.
Example:
Input:3(0000000000000011)
Ouput:5(0000000000000101)
I want a solution in C/C++ language

Answer Posted / satish pandey (gbpuat pantnaga

IN C LANGUAGE

void main()
{
int num,test=0,count,res=0,temp;
printf("\n Enetr the number ");
scanf("%d",&num);
int check=num+1;
do
{
if(num%2==1)
{
res++;
}
num=num/2;
}while(num!=0);
while(test!=1)
{count=0;
temp=check;
do
{
if(temp%2==1)
{
count++;
}
temp=temp/2;
}while(temp!=0);

if(count==res)
{
test=1;
break;
}
else
{
check++;
test=0;
}
}
printf("Next Number is = %d",check);

}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

The difference b/w the compound interest payble half yearly and the simple interest on a certain sum lent out at 10% p.a for 1 year is Rs 25. What is the sum?

1235


A string of alphanumeric is there. Find a string that starts with b and ends with 3 characters.

1343


Using the digits 1,5,2,8 four digit numbers are formed and the sum of all possible such numbers.

1209


SEND + MORE = MONEY. Then what is the value of M + O + N + E + Y ?

1808


If a refrigerator contains 12 cans such that 7 blue cans and 5 red cans. In how many ways can we remove 8 cans so that atleast 1 blue can and 1 red can remains in the refrigerator?

2463


A bag contains 6 black and 8 white balls. One ball is drawn at random. What is the probability that the ball drawn is white?

1138


If log 0.317=……… and log 0.318=………. Then find the value of log 0.319.

1133


What was the aggregate of marks obtained by sajal in all the six subjects?

1367


Two ladies ,two men sit in north east west south position of rectangular table. Using clues identify their position ?

1190


im swetha... is the chances 4 science graduates are less when compared with arts & commerce graduates 4 a bank job? why im asking bcoz, i attended for four banks interview like sbi[2], bank of baroda, karur vysya bank after selected in the written test. i attended interview very well. but not.. why this?

2080


hi...i have got selected for United bank po interview.can anyboby suggest me how to prepare for interview.r there any books for po interview?i am asking because..this s my 1 st bank interview...pls send me interview material if u have any ..my mail id=pruthi_tarun@yahoo.co.in....thank u

2724


can we write the group-1 exam in telugu

1747


When I was married 10 years back my wife was the sixth member of my family. Now I have a baby. Today my father was dead and I had a new baby. Now the average age of my family is the same as that when I was married. Find the age of my father when he was 60.

1060


What number should be added to or subtracted from each term of the ratio 17 : 24 so that it becomes equal 1 : 2.

1375


Subbu starts from a point O at 10.00 am , overtakes Ajay, who is moving in the same direction, at 11.00 a.m. and Bhuvan moving in the opposite direction at 12.00 (noon). If the speed of Bhuvan is one fourth the speed of Subbu, at what time will Ajay and Bhuvan cross each other.

1945