+ 1

Can anyone suggest me a method to convert a decimal number to binary and vice versa?

17th Aug 2017, 2:37 PM
Naman Gogia
Naman Gogia - avatar
11 Réponses
+ 1
How do I print the reverse in c++?
17th Aug 2017, 4:37 PM
Naman Gogia
Naman Gogia - avatar
+ 1
But how will I reverse print it?
17th Aug 2017, 4:47 PM
Naman Gogia
Naman Gogia - avatar
+ 1
Without using an array?
17th Aug 2017, 4:47 PM
Naman Gogia
Naman Gogia - avatar
+ 1
decimal to binary
17th Aug 2017, 4:48 PM
Naman Gogia
Naman Gogia - avatar
0
for(i=n;i<=0;i--) like this... where n=length of that binary number-1 (-1) because arrays starts with 0 so length 5 means 0-1-2-3-4(upto 4)
17th Aug 2017, 4:43 PM
sayan chandra
sayan chandra - avatar
17th Aug 2017, 4:46 PM
sayan chandra
sayan chandra - avatar
0
take the elements in a array using for loop the print it reverse... like i=n;i<=0,i-- n=length of array - 1
17th Aug 2017, 5:00 PM
sayan chandra
sayan chandra - avatar
- 1
i can give you te logic in python okayy?????
17th Aug 2017, 3:14 PM
sayan chandra
sayan chandra - avatar
- 1
here it is... give input like below--> 7 111001 seperated by enter https://code.sololearn.com/cXGWIexb0M5A/?ref=app
17th Aug 2017, 3:53 PM
sayan chandra
sayan chandra - avatar
- 1
in which mode binary to decimal or decimal to binary what exactly your confusion clearly say...
17th Aug 2017, 4:48 PM
sayan chandra
sayan chandra - avatar
- 1
#include<iostream.h> void main() { clrscr(); long int decnum, rem, quot; int binnum[100], i=1, j; cout<<"Enter any decimal number : "; cin>>decnum; quot=decnum; while(quot!=0) { binnum[i++]=quot%2; quot=quot/2; } cout<<"Equivalent binary value of"<<decnum<<" :\n"; for(j=i-1; j>0; j--) { cout<<binnum[j]; } } ##something like this
17th Aug 2017, 5:07 PM
sayan chandra
sayan chandra - avatar