What is the molecular formula of a diamond?
Diamond is an allotrope of Carbon
Allotrope means that it is a form of Carbon but differs in its structural arrangement.
Graphite when introduced to high temperature and pressure undergoes a structural change from being hexagonal planar to being a tetrahedrally bonded lattice.
This structure and ultimately the covalent bonding between the Carbons give Diamond its hardness and thermal conductivity.
Difference in structure of Diamond and Graphite:
Image from: https://d2jmvrsizmvf4x.cloudfront.net/EKKPRMbQqeIpN3MbQj13_small
So ultimately the molecular formula of Diamond is C, just like for graphite but the structure is different and so are the properties.
Hope this helps :)