i know how to add one to a number but i am asking that must the nonce be incremented or generated randomly?
In principle you can do it either way. If you're pulling from a mining pool, they expect you to try every nonce and may consider it abusive if you only try some of them.
how can i add one to the nonce because "42a14695" has a alphabetical character
Please don't take this the wrong way, but if it seriously mystifies you how to increment a hexadecimal number, you have no business writing this kind of code. This is like asking how to add one to seven because "seven" contains a 'v'. How you choose to write a number to communicate with others has nothing to do with how you manipulate it internally. Whether I tell you the number is "seven", "7" or ". . . . . . .", you add one to it the same way. If this is at all mystifying to you, you really should start out with some *much* simpler coding tasks.
and can anybody tell me how to compare the hash with the target?
The same way you compare, say, 571 to 541. You start with the most significant unit and if they're the same, you keep going to less and less significant units until you find a difference. (The hundreds are the same, so try the tens. The tens are different, so the one with the higher tens place is bigger.) Same idea.
You have to try billions of nonces. Anything not dependent on the nonce should be done just once. You take over right where the nonce comes in, so you don't need anything processed prior to that. You're not going to go hashing all those things that never change for each of your 4 billion nonces. That would be awful.