1. Continually take input unless a negative number is given. Input will be only 0/1. That is actually binary representation of a number. You have to determine the decimal representation and total number of digits in decimal representation of that number. Input order MSB to LSB. You CANNOT use array for this.

Sample Input   Sample Output
1
0
0                18 2
1
0
-1

0
1
0               21 2
1
0
1
-1  

asked 05 May, 18:02

beginner%20level's gravatar image

beginner level
293

edited 06 May, 11:15

Mosharraf%20Hosain's gravatar image

Mosharraf Hosain ♦
23618

Can you please provide the question link? Can't understand your problem for bad formatting.

NB: You shouldn't just ask for a homework / problem solution in the forum. These are for you to solve. You can ask for a specific problem if you are really stuck.

(06 May, 06:22) Ashfaqur Rahman

#1. int i=0, dec=0, count=0;

#2. input number, then i=i*10+input (until number < 0)  & sum++

#3. for_loop cheking all digit of i (last to first) dec = dec + digit * pow(2, sum-1); sum--

#4. count how many digit in dec

#5. print
permanent link

answered 06 May, 17:38

alamarif's gravatar image

alamarif
111

edited 07 May, 10:58

Mosharraf%20Hosain's gravatar image

Mosharraf Hosain ♦
23618

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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

Question tags:

×67

question asked: 05 May, 18:02

question was seen: 77 times

last updated: 07 May, 10:58