Cohomology ring of $\mathbb CP^2$ with a 3-cell attached Let $X$ be $\mathbb CP^2$ with a 3-cell $e^3$ attached via $S^2\to \mathbb CP^1\subset \mathbb CP^2$ of degree $p$.
By cellular cohomology, it is easy to see that  $H^k(X,\mathbb Z_p)$ is $\mathbb Z_p$ when $k=1,2,3,4$ and $0$ otherwise. 
I wish to show that the cup product
$$H^2(X,\mathbb Z_p)\times H^2(X,\mathbb Z_p) \to H^4(X,\mathbb Z_p)$$ 
is nontrivial. I am also confused about this $e^3$ attached to $\mathbb CP^2$. I think it probably doesn't affect this cup product but I don't know how to show it rigorously. 
Also, I only know $H^*(\mathbb CP^2, \mathbb Z)\cong (a)/(a^3)$ and I am not sure how it is effected when taking the coefficients to be $\mathbb Z_p$.
Thank you.
 A: Edit: I updated my answer for the updated question, where the attaching map $f_p\colon S^2 \to \mathbb{C}P^2$ has degree $p>1$ and cohomology is taken with $\mathbb{Z}/p$ coefficients. My original answer is below.
Don't forget that the cup product is natural, namely if we consider the inclusion $i\colon \mathbb{C}P^2 \to X$ then we get a commutative diagram
$\require{AMScd}$
\begin{CD}
H^2(X)\times H^2(X) @>{\cup}>> H^4(X)\\
@V{i^*\times i^*}VV @V{i^*}VV \\
H^2(\mathbb{C}P^2)\times H^2(\mathbb{C}P^2) @>{\cup}>> H^4(\mathbb{C}P^2)\\
\end{CD}
for any coefficients. In particular, with $\mathbb{Z}/p$ coefficients the long exact sequence for the cofibration $S^2\stackrel{f_p}{\to} \mathbb{C}P^2 \to X$ shows that the vertical maps are both isomorphisms, so the cup products are the same.

For your second question, 
$$ H^*(\mathbb{C}P^n;R)\cong R[u]/(u^{n+1})$$
for any $R$ and $n$, where $u$ has degree $2$.

Old answer
If the attaching map $S^2 \to \mathbb{C}P^2$ is a degree $\pm 1$ map, then $X$ is homotopy equivalent to the quotient of $\mathbb{C}P^2$ by its $2$-skeleton, which gives $S^4$. 
