0x14. C Bit manipulation Task 01 - humtej1204/holbertonschool-low_level_programming GitHub Wiki
mandatory
Write a function that prints the binary representation of a number.
- Prototype:
void print_binary(unsigned long int n);
- Format: see example
- You are not allowed to use arrays
- You are not allowed to use
malloc
- You are not allowed to use the
%
or/
operators
julien@ubuntu:~/0x14. Binary$ cat 1-main.c
#include <stdio.h>
#include "main.h"
/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
print_binary(0);
printf("\n");
print_binary(1);
printf("\n");
print_binary(98);
printf("\n");
print_binary(1024);
printf("\n");
print_binary((1 << 10) + 1);
printf("\n");
return (0);
}
julien@ubuntu:~/0x14. Binary$ gcc -Wall -pedantic -Werror -Wextra -std=gnu89 1-main.c 1-print_binary.c _putchar.c -o b
julien@ubuntu:~/0x14. Binary$ ./b
0
1
1100010
10000000000
10000000001
julien@ubuntu:~/0x14. Binary$
- GitHub repository: holbertonschool-low_level_programming
- Directory: 0x14-bit_manipulation
- File: 1-print_binary.c