samedi 1 avril 2017

C Program that determines if number in binary has more 1 or 0

I have this assignment for extra points at college:

Write a program in C language that examines if number (int) entered from keyboard has more ones (1) or zeros (0) in it's binary code, and prints out the result.

This is supposed to be done without using loops, because this is our 3rd week of semester and we haven't started learning loops yet.

I thought of testing each digit separately but if the number is long, for example 32 bits, that way is really hard and tiring. Is there an easier way?

Aucun commentaire:

Enregistrer un commentaire