You are not logged in. Please login at to post your questions!


generating numbers containing 0 and 1 only

i wished to write a code in c or c++ that could help me to generate numbers containing only two type of digits(say 0,1) till an appropriate limit (say 100000).eg.0,1,01,00,10,11,110,111,101...and so on.... without traversing from 0 to the actual range (by comparing the individual digits if they are 0 and 1).

asked 05 Apr '15, 16:12

tejasvi96's gravatar image

accept rate: 0%

edited 05 Apr '15, 16:36

use rand()%2 to generate 0 or 1.


answered 06 Apr '15, 01:17

ironmandhruv's gravatar image

accept rate: 20%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 05 Apr '15, 16:12

question was seen: 653 times

last updated: 06 Apr '15, 01:17