i would like to know what should my program do in order to find a block?
Read the information at those links and you'll have the answer to your question. If you can't figure it out from the information provided, you probably aren't capable of writing a workable computer program to accomplish your intended task.
Specifically as stated in one of those links:
The SHA256 hash that identifies each block (and which must have a run of 0 bits) is calculated from the first 6 fields of this structure (version, prev_block, merkle_root, timestamp, bits, nonce, and standard SHA256 padding, making two 64-byte chunks in all) and not from the complete block. To calculate the hash, only two chunks need to be processed by the SHA256 algorithm. Since the nonce field is in the second chunk, the first chunk stays constant during mining and therefore only the second chunk needs to be processed. However, a Bitcoin hash is the hash of the hash, so two SHA256 rounds are needed for each mining iteration. See Block hashing algorithm for details and an example.
Block hashing algorithm is seen at this link (as found in the information from one of those previous links I posted):
https://en.bitcoin.it/wiki/Block_hashing_algorithm