diff --git a/decimalToBinary.cpp b/decimalToBinary.cpp new file mode 100644 index 0000000..07d0514 --- /dev/null +++ b/decimalToBinary.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main(){ + int a[10], n, i; + cin >> n; + + for(i=0; n>0; i++){ + a[i] = n%2; + n = n/2; + } + + for(i=i-1 ;i>=0 ;i--){ + cout << a[i]; + } +} \ No newline at end of file diff --git a/reverseNumber.c b/reverseNumber.c new file mode 100644 index 0000000..57f53d4 --- /dev/null +++ b/reverseNumber.c @@ -0,0 +1,23 @@ +#include + +int main(){ + int num,revNum; + + scanf("%d",&num); + + revNum = reverse_function(num); + printf("\n%d", revNum); + return 0; +} + +int sum = 0, rem; +reverse_function(int num){ + if(num){ + rem = num%10; + sum = sum*10+rem; + reverse_function(num/10); + } + else + return sum; + return sum; +} \ No newline at end of file