#include<iostream>using namespace std;int main(){int count=0;int
count1=0;for(int i=0;i<11;i++){
count=0;for(int j=0;j<4;j++)if((i &(1<<j)) >0){count++;}
count1+=count;}cout<<count1;return 0;}

it will be better if u use java
limit of j will be more in case 100 or 200
so use If Integer.Bitcount() value if it is  int k
then for(int j=0;j<k;j++)
hope u got it


On 24 July 2012 15:09, ruru <soupti...@gmail.com> wrote:

> find no. of 1's in binary format of numbers from 1 to 100. like for
> 1 to 10 answer is 17
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
aviNash

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to