this is ma first thread so hoping for +ve repleis..........

first of all i wud like to tell u tht m at the very basic level(actually basic se bhi neeche ata hun mein)

i have made program to convert decimal to binary

in two ways plzz find out ma mistakes in dese two progs:::::::::::

:::::::

:::::::::

::::::

first of all i wud like to tell u tht m at the very basic level(actually basic se bhi neeche ata hun mein)

i have made program to convert decimal to binary

in two ways plzz find out ma mistakes in dese two progs:::::::::::

Code:

#include<iostream.h> #include<conio.h> #include<process.h> void dectobin(int ,int ); int main() {clrscr(); int decimal; cout<<"enter a decimal integer to convert it to binary :"; cin>>decimal; cout<<"\nIn Binary is :\n"; dectobin(decimal,2); cout<<endl; return 0; } void dectobin(int num,int base) { if(num>0) { dectobin(num/base,base); cout<<num%base; } }

:::::::::

::::::

Code:

#include<iostream.h> #include<conio.h> void dec2bin(int bin[]) { int n; for(int i=0;n!=0;i++) { bin[i]=n%2; } for(int j=i-1;j>=0;j--) bin[j]=bin[i]; cout<<bin[j]<<" "; } getch(); } void main() {clrscr(); int x,y[100]; cout<<"enter a number to convert it into binary :"; cin>>x; cout<<"the binary equivalent is :"; dec2bin(y); }

*Last edited by shabbir; 27Feb2010 at 09:51.. Reason: Code blocks*