+ 1
Can anyone suggest me a method to convert a decimal number to binary and vice versa?
11 Respuestas
+ 1
How do I print the reverse in c++?
+ 1
But how will I reverse print it?
+ 1
Without using an array?
+ 1
decimal to binary
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)
0
check this...
its another method...
http://www.sanfoundry.com/cpp-program-binary-number-into-decimal/
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
- 1
i can give you te logic in python
okayy?????
- 1
here it is...
give input like below-->
7
111001
seperated by enter
https://code.sololearn.com/cXGWIexb0M5A/?ref=app
- 1
in which mode
binary to decimal or decimal to binary
what exactly your confusion clearly say...
- 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