+ Reply to Thread
Results 1 to 2 of 2

Thread: Count number of 1s

  1. #1
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321

    Count number of 1s

    Write a code to count the no.of 1s in a given 16 bit integer.

  2. #2
    rajukonda Guest
    int count = 0;
    while (number != 0)
    {
    if (number % 10 == 1)
    count ++;
    number /= 10;
    }

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find number or just smaller number
    By TopGun in forum Amazon
    Replies: 1
    Last Post: 2nd July 2010, 04:43
  2. Count negative numbers in a matrix
    By Surfer in forum Algorithm/Data Structure Questions
    Replies: 1
    Last Post: 18th March 2010, 22:59

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts