For 1st program you can go like this, check for the number. for example say number is 53...so check for each numbr, first 5 and then 3.
sdmahapatra like this