<PAGE>
 
                                                                    EXHIBIT 11.1

                              MASTECH CORPORATION
                      CALCULATION OF  PER SHARE EARNINGS
                      ----------------------------------
                 (Dollars in thousands, except per share data)
                 ---------------------------------------------
                                  (Unaudited)

<TABLE>
<CAPTION>
                                                                    Three Months Ended                    Nine Months Ended
                                                                    ------------------                    -----------------         

                                                             September 30,      September 30,     September 30,      September 30,
                                                                      1997              1996               1997              1996
                                                             -------------      -------------     -------------      -------------
                                                                                 (Pro Forma                           (Pro Forma
                                                                                Information)                         Information)
<S>                                                          <C>                <C>               <C>                <C>
Weighted average common shares....................                21,656,609        18,200,000         21,655,482        18,200,000
 
Dilutive effect of stock issued within one year
 of the initial public offering...................                       ---            54,600                ---            54,600
 
Effect of shares sufficient to replace capital in
 excess of earnings withdrawn as dividends........                       ---           410,867                ---           410,867
 
Dilutive effect of common stock equivalents                          383,467               ---            199,254               ---
                                                                 -----------       -----------        -----------       -----------
Total weighted average shares.....................                22,040,076        18,665,467         21,854,736        18,665,467
                                                                 ===========       ===========        ===========       ===========
Net income........................................               $     4,541                          $    10,278       
                                                                 ===========                          ===========       
Pro forma net income..............................                                 $     1,440                          $     6,052
                                                                                   ===========                          =========== 
Net income per common share.......................               $      0.21                          $      0.47   
                                                                 ===========                          ===========       
Pro forma net income per common share.............                                 $      0.08                          $      0.32 
                                                                                   ===========                          =========== 
</TABLE>