Find all missing numbers from a given sorted array | C # program for the above approach ; Function to find the missing elements ; Initialize diff ; Check if diff and arr [ i ] - i both are equal or not ; Loop for consecutive missing elements ; Driver code ; Given array arr [ ] ; Function call
using System ; class GFG { static void printMissingElements ( int [ ] arr , int N ) { int diff = arr [ 0 ] - 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] - i != diff ) { while ( diff < arr [ i ] - i ) { Console . Write ( i + diff + " ▁ " ) ; diff ++ ; } } } } static void Main ( ) { int [ ] arr = { 6 , 7 , 10 , 11 , 13 } ; int N = arr . Length ; printMissingElements ( arr , N ) ; } }