h>
#include <conio.h>
include <stdio.h>
main ()
cout<< “
decimal to binary
#include <iostream.h>
void binary(int);
void main(void) {
int number;
if(number <= 1) {
cout << number;
return;
}
remainder = number%2;
binary(number >> 1);
cout << remainder;
1. #include<iostream.h>
2. #include<conio.h>
3. void main()
4. {
5. clrscr();
6. unsigned long int y,i=0,j=0,r,k[50];
7. unsigned long a,x,b[50];
8. cout<<"\nEnter a decimal no. ";
9. cin>>a;
10. y=a;
11. x=a-y;
12. while(y>0)
13. {
14. r=y%2;
15. k[i]=r;
16. i++;
17. y=y/2;
18. }
19. int m=0;
20. while(m<10)
21. {
22. x=x*2;
23. b[j]=int(x);
24. j++;
25. m++;
26. if(x>1)
27. x=x-1;
28. else
29. if(x==0)
30. break;
31. }
32. cout<<"\nDecimal no. "<<a<<" = ";
33. if(a>1)
34. {
35. for(int e=i-1;e>=0;e--)
36. cout<<k[e];
37. cout<<".";
38. for(int g=0;g<m;g++)
39. cout<<b[g];
40. }
41. else
42. {
43. cout<<"0.";
44. for(int f=0;f<m;f++)
45. cout<<b[f];
46. }
47. cout<<" in binary no. system";
48. getch();
49. }
So binary of 18 is 10010
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <conio .h>
using namespace std;
void main()
{
int dec,rem,i=1,sum=0;
cout< <"Enter the decimal to be converted:"<<endl;
cin>>dec;
do
{
rem=dec%2;
sum=sum + (i*rem);
dec=dec/2;
i=i*10;
}while(dec>0);
cout< <"The binary of the given number is:"<<sum<<endl;
getch();
}
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main ()
break;
case 2:
withdraw(); /*to withdraw money*/
break;
if(mon>=20)
{
if(mon!=30)
{
f=mon/50; /*decides the notes of $50*/
rem=mon%50;
if(rem!=20)
{
if (rem==10||rem==30)
{
f-=1;
rem+=50;
}
}
t=rem/20; /*decides the notes of $20*/
e=rem%20;
if(e==0)
{
cout<<endl<<"Nos. of 50$ note : "<<f;
cout<<endl;
cout<<"Nos. of 20$ note : "<<t<<endl;
cout<<"TOTAL AMOUNT : "<<mon<<endl;
}
else
cout<<endl<<"This amount is not possible... Please try again"<<endl;
}
else /*if amount is not possible*/
{
cout<<endl;
cout<<"This amount is not possible... Please try again"<<endl;
}
}
else
{
cout<<endl;
cout<<"This amount is not possible... Please try again"<<endl;
}