Write a code to count the no. of 1s in a binary representation of a number?
Submitted by: AdministratorI am writing for Microcontrollers. ldi r16,$F0 ldi r17,$08 ldi r18,$00 ldi r19,$00 loop: rol r16 back: brcs one inc r19 dec r17 brne loop end:rjmp end one:inc r18 rjmp back
int count1s =0; while(num != 0){ if(num & 1 == 1){ count1s++; } num= num>>1; } printf("%d", count1s);
Submitted by: Administrator
int count1s =0; while(num != 0){ if(num & 1 == 1){ count1s++; } num= num>>1; } printf("%d", count1s);
Submitted by: Administrator
Read Online Hardware and Software Design Job Interview Questions And Answers
Top Hardware and Software Design Questions
☺ | Explain Difference between RISC and CISC? |
☺ | What is a Turing machine? |
☺ | What is binary search, traversal, hashing? |
☺ | Explain Memory taken for char *, int * etc.? |
☺ | How does the browser know to go to a certain IP address when you enter a domain like globalguideline.com? |
Top PC Hardware Categories
☺ | Motherboard Interview Questions. |
☺ | Basic Computer Interview Questions. |
☺ | Embedded Systems Interview Questions. |
☺ | A + (Plus) Hardware Interview Questions. |
☺ | Computer Architecture Interview Questions. |