2. Write a c program to convert decimal number to octal number.

3. Write a c program to convert decimal number to hexadecimal number.

4. Write a c program to convert octal number to binary number.

3. Write a c program to convert decimal number to hexadecimal number.

4. Write a c program to convert octal number to binary number.

6. Write a c program to convert octal number to hexadecimal number.

8. Write a c program to convert hexadecimal number to octal number.

9. Write a c program to convert hexadecimal number to decimal number.

10. Write a c program to convert binary number to octal number.

9. Write a c program to convert hexadecimal number to decimal number.

10. Write a c program to convert binary number to octal number.

12. Write a c program to convert binary number to hexadecimal number.

13. C program for addition of binary numbers .

14. C program for multiplication of two binary numbers.

15. C program fractional binary conversion from decimal.

16. C program for fractional decimal to binary fraction conversion.

17. C program to convert decimal number to roman.

18. C program to convert roman number to decimal number.

19. C program to convert each digits of a number in words

20. C program to convert currency or number in word.

13. C program for addition of binary numbers .

14. C program for multiplication of two binary numbers.

15. C program fractional binary conversion from decimal.

16. C program for fractional decimal to binary fraction conversion.

17. C program to convert decimal number to roman.

18. C program to convert roman number to decimal number.

19. C program to convert each digits of a number in words

20. C program to convert currency or number in word.

## 38 comments:

thanks to ur great effort........ur work has really been helpful to me n will always be grateful to u.....

thanks!

aayush.

truly i feel great to come here

I see your algorithm logic for this uses value 'remainder' and your code declares a variable long int remainder; but this is unused in the program? I'm not sure why!

Yes you are correct. No need to declare remainder. Thanks

What about negative decimal numbers as input, will it work?

what if the number has a fractional part?

wtf its actually a good question.

how can i save the new binary number in a new array instead of printing it?

thanks in advance

thankx for your help your solution was really very much helpful. i really felt great. Thankx

how can you convert a decimal array into binary one using recursion?

example:

(decimal) 1,2,3,4,5 => (binary)0001,0010, 0011, 0100, 0101

plz answer to olga kuzmin's question..

dude,send me the answer if u have got it.

thanks a lot sir! it helps me a lot!

What if the decimal number is 0? It won't enter the loop

@olga====apply the conversion code in a for loop that trace throufh the array

There is one 0 (zero) more than should be,in the code(last FOR):

for(j = i -1 ;j> 0;j--)

there should be J>1 not 0.

were should i put the clrscr(); ??? thanks

Hello dear!!,

you here printing one by one number. But when you should print it as a number!! Suppose, you need to use the binary conversion as a number,then your logic does not work.

Thanks.

#include

#include

int main()

{ long int decimal,binr=0;

int bin=0,rem,i;

printf("enter the decimal number:");

scanf("%ld",&decimal);

for(i=1;decimal!=0;i++)

{ rem=decimal%2;

binr= binr*10 +rem;

decimal=decimal/2;

}

for(i=0;binr!=0;i++)

{ rem = binr%10;

bin= bin*10 +rem ;

binr=binr/10;

}

printf("the binary equivalent is: %ld",bin);

getch();

return 0;

}

This is a code with0ut using a array and can be used for decimal to octal num also anly the change is to make 8, where 2 is written.

#include

void binary(int );

int main()

{

int n;

scanf("%d",&n);

binary(n);

return 0;

}

void binary(int p)

{

if(p==1)

printf("1");

else

{

binary(p/2);

printf("%d",p%2);

}

}

Hey, quick question about the value of i. Should the value of i be 100 and not 1. If it 1, the for loop with j would give an error? I'm confused about that.

Nevermind. I got the point! Thanks!

how to write a program to print the boundary of a matrix

why do i get this and each number of the binary is in a different line and how to fix it

for instance the number 4 shows as

1

0

0

its simple we can just take decimal part and multiply by 2. take reminder again multiply by 2. Repeat until we get 0

#include

#include

#define CHK_BIT(num,pos) (num&(0x01<<(pos-1)))

void dec2bin(int num);

main(){

int num;

printf("Enter the Number");

scanf("%d",&num);

dec2bin(num);

}

void dec2bin(int num){

int i;

for(i=31; i>0; i--){

if(CHK_BIT(num,i))

printf("1");

else

printf("0");

}

printf("\n");

}

Write a program to Convert i) Decimal to Binary ii) Binary to Decimal number at kao paro ?

#include "stdafx.h"

#include "iostream"

#include "conio.h"

using namespace std;

int main()

{

int i=2;

int n,a;

cout<<"enter a decimal number"<<"\n";

cin>>n;

int arr[32];

if(n>0)

{

arr[0]=0;

}

else

{

arr[0]=1;

}

if(arr[0]==1)

{

n=n/-1;

}

a=n;

while(a>1)

{

arr[i]=n%2;

a=a/2;

n=a;

i=i+1;

};

arr[1]=1;

for(int j=i;j<32;j++)

{

arr[j]=0;

}

cout<<"the given array is"<<"\n";

cout<<arr[0]<<arr[1];

for(int j=2;j<32;j++)

{

cout<<arr[j];

}

return 0;

}

#include "stdafx.h"

#include "iostream"

#include "conio.h"

using namespace std;

int main()

{

int i=2;

int n,a;

cout<<"enter a decimal number"<<"\n";

cin>>n;

int arr[32];

if(n>0)

{

arr[0]=0;

}

else

{

arr[0]=1;

}

if(arr[0]==1)

{

n=n/-1;

}

a=n;

while(a>1)

{

arr[i]=n%2;

a=a/2;

n=a;

i=i+1;

};

arr[1]=1;

for(int j=i;j<32;j++)

{

arr[j]=0;

}

cout<<"the given array is"<<"\n";

cout<<arr[0]<<arr[1];

for(int j=2;j<32;j++)

{

cout<<arr[j];

}

return 0;

}

the code will not work for negative decimal numbers & also for decimal numbers with fraction part..!!

here binaryNumber[i++] is used for storing binary numbers

#include

int i=0;

int reminder[100];

binary(int decimal)

{

if(decimal==0)

{

reminder[i++]=decimal;

}

else if(decimal==1)

{

reminder[i++]=decimal;

}

else

{

reminder[i++]=decimal%2;

decimal=decimal/2;

binary(decimal);

}

}

int main()

{

int decimal,j;

printf("Enter a decimal number :");

scanf("%d",&decimal);

binary(decimal);

for(j=i-1;j>=0;j--)

printf("%d",reminder[j]);

return 0;

}

HI can i use dynamic memory to solve this problem?Is this approach considered appropriate? And ofcourse, i have written the program in c++ instead of c. But i only wanted to confirm if this approach is legible.

#include

#include

using namespace std;

int to_binary(int num){

bool *binary_sequence;

if (num==1) return 1;

else if(!num)return 0;

int counter=0;

while (num>1){

if (counter==0)

{

binary_sequence=new bool[counter+1];

binary_sequence[0]=num%2;

}

else

{

bool temp[counter];

for(int i=0;i=0;index--)

{

result=result=result*10;

result=result+binary_sequence[index];

}

delete [] binary_sequence;

return result;

}

int main()

{

int n;

cout<<"Enter any number "<>n;

cout<<"Binary equivalent "<<endl;

cout<<to_binary(n);

getche();

return 0;

}

Can someone tell me programme to convert decimal to binary by call by value method

what if the given decimal number is of unknown no. of digits(no.of digits<1000)

Super blog and your presenting style about the weekly that's are very appreciated good work.

weekly

Thanks this is a very nice C program to convert decimal to binary number

#include

#include

void main()

{

int no , r ;

int i=1;

int s=0;

printf("Enter the decimal number :\n");

scanf("%d",&no);

while( no !=0)

{

r = no % 2;

no = no / 2;

s = s + ( no * i ) ;

i = i * 10;

}

printf("Dcimal to Binary = %d " , s);

getch();

}

Post a Comment