Skip to content

Commit

Permalink
Decimal to Binary Converter
Browse files Browse the repository at this point in the history
  • Loading branch information
Anikkkkettt committed Oct 2, 2021
1 parent 74942ca commit 6113970
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions C/decimal_to_binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<stdio.h>
#include<math.h>
int change(int n);
int main()
{
int n;
printf("Enter a number in decimal : ");
scanf("%d",&n);
int m = change(n);
printf ("The number %d in binary is %d",n,m);
}
int change(int n)
{
int dec=0,i=1,rem;
while(n!=0)
{
rem = n % 2;
n /= 2;
dec += rem * i;
i *= 10;
}
return dec;
}
2 changes: 2 additions & 0 deletions CONTRIBUTERS.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| Shruti Jha | [@ShrutiJha31](https://github.com/ShrutiJha31/) | 0 |
| Jobin | [@Jobin01334](https://github.com/Jobin01334) | 1 |
| Richard Timothy | [@RichardTimothy1307](https://github.com/RichardTimothy1307/) | 0 |
| Aniket Nayek | [@AniketNayek3101](https://github.com/AniketNayek3101) | 0 |
| Sumit Soni | [@isumit19](https://github.com/isumit19/) | 0 |
| Siddarth Awasthi | [@siddarth308](https://github.com/siddarth308/) | 0 |
| Hero Tiwari | [@Skywalkers-24](https://github.com/Skywalkers-24/) | 0 |
Expand Down Expand Up @@ -43,6 +44,7 @@
| Sandi Aris | [@Sandi-aris](https://github.com/sandi-aris) | 0 |
| Misbahud Din | [@Misbahud-Din](https://github.com/Misbahud-Din) | 0 |
| Ganzabahl | [@Ganzabahl](https://github.com/Ganzabahl) | 0 |

| Ashish | [@ashish-garg18](https://github.com/ashish-garg18) | 0 |
| Mitarth Jain | [@mitarthjain](https://github.com/mitarthjain) | 0 |
| Arisandi | [@arisandi1](https://github.com/arisandi1) | 0 |
Expand Down

0 comments on commit 6113970

Please sign in to comment.