Skip to content

Commit

Permalink
Merge pull request keshavsingh4522#684 from AniketNayek3101/master
Browse files Browse the repository at this point in the history
Decimal to Binary Converter
  • Loading branch information
keshavsingh4522 committed Oct 2, 2021
2 parents 7bc061d + 6113970 commit f8a4ca0
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 @@ -11,6 +11,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 @@ -44,6 +45,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 f8a4ca0

Please sign in to comment.