The molecular orbital electronic configuration of both B2 and C2 are:
B2:
[σ1s]2[σ*1s]2[σ2s]2[σ*2s]2[π2px]1[π2py]1
C2:
[σ1s]2[σ*1s]2[σ2s]2[σ*2s]2[π2px]2[π2py]2
Since, B2 has two unpaired electrons, therefore, B2 is paramagnetic C2 has no unpaired electron, therefore, C2 is diamagnetic.