What exactly am I being asked in this question? I don't need the answer, just the interpretation. 
Write a program that inputs a whole number N and outputs the percentage of relatively prime pairs of numbers a, b in the range 1 to N. 

For some reason, I'm having difficulty understanding the question. Do I need to calculate the probability of a and b being co-primes? Do I need to find the gcd? I’m not sure what I'm being asked.
Also, please provide an end answer or an example, so that I have something to check my answer against and know that I'm on the right track. Thank you.
 A: Take $N=6$ as an example. There are $\binom62=15$ pairs of integers in the range from $1$ through $N$. Among them the pairs $\{1,2\},\{1,3\},\{1,4\},\{1,5\},\{1,6\},\{2,3\},\{2,5\},\{3,4\},\{3,5\},\{4,5\}$, and $\{5,6\}$ are relatively prime. That’s $11$ relatively prime pairs out of a total of $15$ pairs, or $73.\overline3$ percent.
Added: Note that I’ve assumed that you’re being asked about unordered pairs of distinct numbers; I think that this is the likeliest interpretation, but it would be a good idea to check, if you have any way to do so. The most straightforward approach is simply to run $i$ from $1$ to $N-1$, and within that $j$ from $i+1$ to $N$, checking $\gcd(i,j)$.
A: As @Greg Martin's comment points out, the question is ambiguous. I such case, the safest way to deal with it is as four questions, with four answers, where the denominators are respectively $n^2$, $n(n-1)$, $\frac12n(n+1)$, and $\frac12n(n-1)$. Obviously, this is laborious; but you will be safe in having covered all the possible interpretations.
A: I think you should interpret the question as finding, for two independent random variables $X,Y$ each uniformly distributed over the set $[n]=\{1,2,\ldots,n\}$, the probability that $\gcd(X,Y)=1$. While other interpretations of the question are possible, this seems the most natural one to me, and in addition it is computationally easiest to handle.
You can do this by two nested loops over $[n]$, but there is a more efficient way if $n$ is large. The value of $\gcd(X,Y)$ is always a value in$~[n]$, and for a given $d\in[n]$ it is easy to find the probability that $\gcd(X,Y)$ is a multiple of$~d$, namely $\bigl(\frac{\lfloor n/d\rfloor}n\bigr)^2$: both $X$ and $Y$ must be multiples of $d$, and there are $\lfloor n/d\rfloor$ such multiples. The constant factor $\frac1{n^2}$ is not very interesting, so define $f(d)=\lfloor n/d\rfloor^2$ for $d\in[n]$; then the number $g(d)$ of pairs $(x,y)\in[n^2]$ with $\gcd(x,y)=d$ satisfies
$$
  \sum_{k=1}^{\lfloor n/d\rfloor}g(kd)=f(d).
$$
From this you can solve $g(d)=f(d)-\sum_{k=2}^{\lfloor n/d\rfloor}g(kd)$ by downwards recursion. You can improve this even more by observing that $g(d)$ only depends on the integer value $\lfloor n/d\rfloor$, so only about $2\sqrt n$ values of $g$ need to actually be computed and tabulated. The final value computed $g(1)$ gives your answer $\frac{g(1)}{n^2}$.
As a sample result, for $N=30$ one finds $g(1)=555$. From more sample values, see OEIS:018805.
A: You could compute $\sum_{n=1}^N \phi(n)$, which would be $O(N log N)$, to find the number of coprime pairs $1 \leq a<b\leq N$.
