<PAGE>
 
                                                                    EXHIBIT 11.1


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


<TABLE>
<CAPTION>
                                                 For the Three Months Ended September 30,
                                                 ----------------------------------------
                                                      1998                      1997
                                                      ----                      ----
<S>                                              <C>                         <C>
Basic earnings per share:
Net income                                           $10,204                      $4,555
                                                 ============                ============
Divided by:
  Weighted average common shares                  49,017,829                  44,936,218
                                                 ============                ============

Basic earnings per share                               $0.20                       $0.10
                                                 ============                ============

Diluted earnings per share:
Net income                                           $10,204                      $4,555
                                                 ============                ============

Divided by the sum of:
  Weighted average common shares                  49,017,829                  44,936,218
  Dilutive effect of common stock equivalents        832,171                     763,834
                                                 ------------                ------------
  Diluted average common shares                   49,850,000                  45,700,052
                                                 ============                ============

Diluted earnings per share                             $0.20                       $0.10
                                                 ============                ============
</TABLE>

<TABLE>
<CAPTION>

                                                  For the Nine Months Ended September 30,
                                                 ----------------------------------------
                                                      1998                      1997
                                                      ----                      ----
<S>                                              <C>                         <C>
Basic earnings per share:
Net income                                           $22,901                     $10,565
                                                 ============                ============
Divided by:
  Weighted average common shares                  48,961,044                  44,933,964
                                                 ============                ============

Basic earnings per share                               $0.46                       $0.23
                                                 ============                ============

Diluted earnings per share:
Net income                                           $22,901                     $10,565
                                                 ============                ============

Divided by the sum of:
  Weighted average common shares                  48,961,044                  44,933,964
  Dilutive effect of common stock equivalents        849,357                     396,008
                                                 ------------                ------------
  Diluted average common shares                   49,810,401                  45,329,972
                                                 ============                ============

Diluted earnings per share                             $0.46                       $0.23
                                                 ============                ============
</TABLE>

   
                                      34