A function f from the set of natural numbers to the set of integers defined by
$f(n) \begin{cases}\frac{n-1}{2}, & \text { when } n \text { is odd } \\ -\frac{n}{2}, & \text { when } n \text { is even }\end{cases}$
(a) neither one-one nor onto
(b) one-one but not onto
(c) onto but not one-one
(d) one-one and onto
Injectivity:
Let x and y be any two elements in the domain (N).
Case-1: Both $x$ and $y$ are even.
Let $f(x)=f(y)$
$\Rightarrow \frac{-x}{2}=\frac{-y}{2}$
$\Rightarrow-x=-y$
$\Rightarrow x=y$
Case-2: Both $x$ and $y$ are odd.
Let $f(x)=f(y)$
$\Rightarrow \frac{x-1}{2}=\frac{y-1}{2}$
$\Rightarrow x-1=y-1$
$\Rightarrow x=y$
Case-3 : Let $x$ be even and $y$ be odd.
Then, $f(x)=\frac{-x}{2}$ and $f(y)=\frac{y-1}{2}$
Then, clearly
$x \neq y$
$\Rightarrow f(x) \neq f(y)$
From all the cases, $f$ is one-one.
Surjectivity:
Co-domain of $f=Z=\{\ldots,-3,-2,-1,0,1,2,3, \ldots\}$
Range of $f=\left\{\ldots, \frac{-3-1}{2}, \frac{-(-2)}{2}, \frac{-1-1}{2}, \frac{0}{2}, \frac{1-1}{2}, \frac{-2}{2}, \frac{3-1}{2}, \ldots\right\}$
$\Rightarrow$ Range of $f=\{\ldots,-2,1,-1,0,0,-1,1, \ldots\}$
$\Rightarrow$ Range of $f=\{\ldots,-2,-1,0,1,2, \ldots\}$
$\Rightarrow$ Co-domain of $f=$ Range of $f$
$\Rightarrow f$ is onto.
So, the answer is (d).