The teachings of Allah tell us that the sin will be held against him until Judgement Day. So, what is a guy supposed to do to receive Allah's forgiveness, if he ever accidentally or intentionally commits a sin?
First, he must feel remorseful about whatever sin he has committed then he must repent his actions to Allah by saying, "My Lord please forgive me."
He must make full restitution for the sin committed, if at all possible, but remember once a life is taken it ain't coming back. He must avow never to do it again. Allah has promised to forgive a man of his sins if the sinner seeks forgiveness sincerely and directly from Allah, but and this is a big but, if he continues to repeat his offence, all he has to do is repeat the process over again and keep on asking for forgiveness. It will eventually be granted when the sinner becomes sincere.
When people's rights or safety are concerned such as; theft, murder or arson and a few others, there are prescribed penalties, which must be paid in this life as consequences for the offenders actions. We here in the West agree that such penalties are barbaric, such as the cutting off of hands, noses, ears and toes for repeating theft offenders, or the public flogging for certain crimes like fornication, or the death penalty for murder and treachery.
It is said that Allah records all good and bad deeds. If you intended to do good but didn't, Allah will know about it, he writes it down in his little black book, with the worship of himself as one full good deed.
Personal moral sins done by someone in private only require the four-step process of repentance to be set straight in the eyes of Allah.
It is written somewhere in the Qurán, well at least in, The Complete Idiot's Guide to Understanding Islam that;
Muhammad said, "Allah has recorded both good and bad deeds. Whoever intended to do a good deed and did not do it, Allah writes it down with Himself as a full good deed. But if he intended to do it and did it, Allah writes it down with Himself as worth from ten to seven hundred good deeds, or many times over. But if he intended to do a bad deed and did not do it, Allah writes it down with Himself as a full good deed, but if he intended it and did it, Allah writes it down as one bad deed."