cpp program to implement pcm