# how to print binary of 1 in 32 bit snippet in c

## how to print binary of 1 in 32 bit

user7152

``````#include<stdio.h>
void bin(unsigned n)
{
unsigned i;
for (i = 1 << 31; i > 0; i = i / 2)
(n & i) ? printf("1") : printf("0");
}

int main(void)
{
bin(7);
printf("\n");
bin(4);
}
``````

## how to print binary of 1 in 32 bit

user1236

``````# Python3 Program for the binary
# representation of a given number

def bin(n):

if n > 1:
bin(n // 2)

print(n % 2,end = "")

if __name__ == "__main__" :

bin(7)
print()
bin(4)

# This code is contributed by ANKITRAI1
``````

## how to print binary of 1 in 32 bit

user306

``````# Python 3 implementation of above approach

# Function to convert decimal to
# binary number

def bin(n):

if (n > 1):
bin(n >> 1)
print(n & 1, end="")

# Driver code
bin(131)
print()
bin(3)

# This code is contributed by PrinciRaj1992
``````

## how to print binary of 1 in 32 bit

user4991

``````// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;

// Function to convert decimal
// to binary number
void bin(unsigned n)
{
if (n > 1)
bin(n >> 1);

printf("%d", n & 1);
}

// Driver code
int main(void)
{
bin(131);
printf("\n");
bin(3);
return 0;
}
``````

## how to print binary of 1 in 32 bit

user289

``````// Java implementation of the approach

class GFG {

// Function to convert decimal
// to binary number
static void bin(Integer n)
{
if (n > 1)
bin(n >> 1);

System.out.printf("%d", n & 1);
}

// Driver code
public static void main(String[] args)
{
bin(131);
System.out.printf("\n");
bin(3);
}
}
/*This code is contributed by PrinciRaj1992*/
``````