I am getting runtime error. please check

Modified Code

Your mistakes

  1. inc the size of temp array also
  2. instead of int a[n];
    use int a[100000];
    int a[n] is not correct because at compile time n is garbage