Activity Selection to maximize the number of activity executions
Note: your code doesn't currently compile for at least two reasons: you are not telling the compiler cout and endl live in the std namespace, and you can't declare your arrays start and end because n is not known at compile-time (instead, you'd have to use dynamic memory allocations).

In any case, your code smells like your background might be in C (but then you'd probably also know about dynamic memory... well, anyway). Indeed, with C++, you typically define variables as close to their site of usage. Moreover, you could take advantage of the algorithms and data structures provided by the language.


  
  Is there a better approach than sorting arrays and comparing?
  


Essentially no: you must sort the arrays (with no additional knowledge, you can't beat the log-linear bound). This dominates your runtime, but it is scalable and practical enough that you don't have to worry about it.


  
  What is a better way to sort the two arrays on the basis of the second array?
  


Because start and end times are logically and tightly coupled (i.e., something is wrong if we suddenly lose the correspondence), it's a good idea to tie them together. For that reason, we can use std::pair. To store such objects, we can use a dynamic array, i.e., std::vector. For sorting that according to the second element, we can use std::sort.

To summarize, we could proceed along the following lines (I'm taking the liberty to omit reading input to avoid clutter):

#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;vector&gt;

typedef std::vector&lt;std::pair&lt;int, int&gt; &gt; PairList;

int activitySelection(const PairList&amp; p) 
{
    PairList s(p);
    std::sort(s.begin(), s.end(), [](const auto&amp; x, const auto&amp; y) {
        return x.second &lt; y.second;
    });

    int end = s[0].second;
    int count = 1;

    for (int i = 1; i &lt; s.size(); ++i)
    {
        if (s[i].first &gt;= end)
        {
            ++count;
            end = s[i].second;
        }
    }

    return count;
}

int main()
{
    PairList v{ {1,2},{3,4},{2,6},{5,7},{8,9},{5,9} };
    std::cout &lt;&lt; activitySelection(v) &lt;&lt; "\n";
}