bcd to char c code example

Example 1: bcd to char c

class Person{      private: int Code;  char Name[25];
                                         public: Person ( int Code=23, char *Name =”Unknow”);     
                                                     char *GetName( ); void SetName(char *Name);
                                         protected: void Input( ); void Output( );
                               }; 
           class Employee: protected Person{                    
                        protected: int hour; float Salary; static float Rate;
                         public: void Indata( ); void Outdata( );
                                                        };

  class Company: public Employee{                         
           public:  inline float Income( );
                      friend void Sort(Company a[45],int n); // by Name
                      friend void Del_Employee(Company obj[45],int n); // by Salary                      
                               };

Example 2: bcd to char c

void BCD_To_ASCII(unsigned char bcd_value, char * p_ascii_text)
{
  //--------------------------------------------------
  // BCD contains digits 0 .. 9 in the binary nibbles
  //--------------------------------------------------
  *p_ascii_text++ = (bcd_value >> 4)  + '0';
  *p_ascii_text++ = (bcd_value & 0x0f) + '0';
  *p_ascii_text = '\0';
  return;
}

Tags:

C Example