<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 June 30,                     
                                                          ----------------------------------                      
                                                                 1998              1997
                                                                 ----              ----
<S>                                                         <C>                 <C>
Basic earnings per share:                                                   
Net income                                                       $5,753             $3,841
                                                            ===========         ==========
Divided by:
  Weighted average common shares                             48,972,618         44,933,411   
                                                            ===========         ==========

Basic earnings per share                                          $0.12              $0.08
                                                            ===========         ==========

Diluted earnings per share:
Net income                                                       $5,753             $3,841
                                                            ===========         ==========
Divided by the sum of:
  Weighted average common shares                             48,972,618         44,933,411   
  Diluted effect of common stock equivalents                    837,418            266,765
                                                            -----------         ----------
  Dilutive average common shares                             48,809,936         45,200,176
                                                            ===========         ==========
Diluted earnings per share                                        $0.12              $0.08
                                                            ===========         ==========
<CAPTION>
                                                           For the Six Months Ended June 30,                     
                                                           --------------------------------                      
                                                                 1998              1997
                                                                 ----              ----
<S>                                                         <C>                 <C>
Basic earnings per share:                                                   
Net income                                                      $12,697             $6,010
                                                            ===========         ==========
Divided by:
  Weighted average common shares                             48,931,894         44,932,812   
                                                            ===========         ==========

Basic earnings per share                                          $0.26              $0.13
                                                            ===========         ==========

Diluted earnings per share:
Net income                                                      $12,697             $6,010
                                                            ===========         ==========
Divided by the sum of:
  Weighted average common shares                             48,931,894         44,932,812   
  Diluted effect of common stock equivalents                    858,425            212,294
                                                            -----------         ----------
  Dilutive average common shares                             49,790,319         45,145,106
                                                            ===========         ==========
Diluted earnings per share                                        $0.26              $0.13
                                                            ===========         ==========
</TABLE>