Tuesday, July 8, 2014

Binary Program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;
 
main()
{
  int n, c, k;
 
  cout<<"Enter an integer in decimal number system\n";
  cin>>n;
 
  cout<<"in binary number system is:\n"<<n;
 
  for (c = 31; c >= 0; c--)
  {
    k = n >> c;
 
    if (k & 1)
      cout<<"1";
    else
      cout<<"0";
  }
 
  cout<<"\n";
 
  return 0;
}
                        Sa tinood lang wala ko kasabot sa dagan sa program.           
     

No comments:

Post a Comment