Write a program that gives us no. Of 1's and 0's when we enter a decimal no? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 3

Write a program that gives us no. Of 1's and 0's when we enter a decimal no?

Output pleas enter no= 7 no.of 1's= 3 no. of 0's=2

24th Oct 2017, 9:27 AM
Rashid Nazeer Khan
Rashid Nazeer Khan - avatar
2 Answers
+ 3
I would get the binary number of it, convert it to a string and in a for loop, count 0's and 1's.
24th Oct 2017, 9:39 AM
Mert Açıkportalı
Mert Açıkportalı - avatar
- 1
please write your coding here it's challenge for MR. and number should be given by the user ok
24th Oct 2017, 10:25 AM
Rashid Nazeer Khan
Rashid Nazeer Khan - avatar