Gray to Binary and Binary to Gray conversion | C ++ program for above approach ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int greyConverter ( int n ) { return n ^ ( n >> 1 ) ; } int main ( ) { int n = 3 ; cout << greyConverter ( n ) << endl ; n = 9 ; cout << greyConverter ( n ) << endl ; return 0 ; }