Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions BinaryToDecimal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//ONLY FUNCTIONS ARE GIVEN HERE

#include <stdio.h>

int decToBin(int);
int rev(int);

int main(){

printf("Binary of 13 is : %d",decToBin(13));

return 0;
}

int rev(int x){

int res=0;
while(x!=0){
res=res*10+x%10;
x/=10;
}
return res;

}

int decToBin(int x){

int res=0;
while(x!=0){
res=res*10+x%2;
x/=2;
}
return rev(res);
}