- Full Information About Artificial Intelligence | What is AI?
- Most Common Important 70+ Shortcut Keyboard Keys
- Stars Square Pattern
- Fascinating Number or Not in C and CPP
- Implement queue using linked list c program
- Calculate the GCD | Euclidean algorithm | c and cpp programming language
- Linear search in c | Algorithm of Linear search | c programming
- A C program for checking whether a given line is a comment
- C program to convert decimal to binary without array
- Voting program in C language using switch case
- C program to check eligible for vote
- Insertion and deletion in double linked list in c program
- File read in C | File Handling | How to read File
- C program to replace vowels with special characters
- Call by Reference in C programming language
- Function call by value in c programming language
- Program to print a message without using semicolon in c programming
- User login system in c programming language
- How to make swastik in c and cpp programming language
- Print numbers from 1 to 100 using while loop c and cpp program
- Simple Macro Substitution(#define) in c and cpp programming language
- Insertion and Deletion of all operation at singly Linked list in c programming langauge
- Write a program to count the digit in a number
- Program to calculate the power of given numbers by user in c and cpp
- Sum of digit calculate program
- Write a program to reverse a number
- Floyd Triangle | Programs | Algorithm
- Program to check whether number is Disarium Number
- Sunny Number in programming
- Happy Number | with Example and Programs
- Display Name of the month by accepting digit of the month | c programming
- Spy Number | c programming
- 9 basic program in cpp programming language
- Automorphic number | c programming language
- C programming restaurant menu code lapmos
- Neon Number c programming language
- Strong Number in C programming What is Strong Number
- Leap Year | Leap year program in c
- Pascal Triangle C programming
- Check Palindrome Number in c
- Print Fibonacci Series in c
- Swap two number without using third variable c programming langauge
- Swap two number c programming
- Largest Number c programming language
- Prime number program in c
- What is the mean by Software Engineering?

We can convert any **decimal number** into **binary number** in c without using an array.

A Decimal number is a **base 10** of number because it ranges goes from 0 to 9, in decimal number there are total 10 digits between 0 to 9. Any combination of digits is decimal number. For Example: 33, 782, 7, 0, 5, etc.

A binary number is a **base 2** of number because it ranges goes from 0 to 1, it has only two digits 0 and 1. Any combination of digits is binary number. For Example: 0110001, 111001, 101, etc.

Decimal | Binar |
---|---|

1 | 1 |

2 | 10 |

3 | 111 |

4 | 100 |

5 | 101 |

6 | 110 |

7 | 111 |

8 | 1000 |

9 | 1001 |

10 | 1010 |

- Run the loop while n is greater than 0.
- Calculate the remainder and store the value in j variable, after this initialized, a variable temp which store the power of 10 after every iteration.
- bin += j * temp → here we store the new bit in bin variable here bin variable store the binary of the digit.
- after perform these operation than remove the last bit of the number using n = n / 2.
- Exit to the loop.
- print the binary of the digit given by user.
- Exit the program.

```
#include <stdio.h>
#include <math.h>
int main() {
int n, i, j, bin = 0, temp;
printf("Enter the Decimal Number : ");
scanf("%d", &n);
temp = n;
for(i = 0; n > 0; i++){
j = n % 2;
int temp = pow(10, i);
bin += j * temp;
n = n / 2;
}
printf("\nBinary of %d is : %d", temp, bin);
return 0;
}
/*
Enter the Decimal Number : 34
Binary of 34 is : 100010
*/
```

```
#include <stdio.h>
#include <math.h>
int main() {
int n, i = 0, bin = 0, temp;
printf("Enter the Decimal Number : ");
scanf("%d", &n);
temp = n;
while(n > 0){
int temp = pow(10, i);
bin += (n % 2) * temp;
n = n / 2;
i++;
}
printf("\nBinary of %d is : %d", temp, bin);
return 0;
}
/*
Enter the Decimal Number : 34
Binary of 34 is : 100010
*/
```

🖤 0

Buy me coffee ☕

## Comments

Oops!