cd is not a program, it's a built-in command. The built-in command are directly built into the shell.
To implement cd, you basically need to
- Use
chdir() to change the current directory
- Update some environment variables (like Klas Lindback said:
OLDPWD and PWD)