Roopa Bhuvaneswari wrote: . . . i want logic for this program please help me...
You will have to work out the logic for your programs yourself, I am afraid. Write it down on paper, then you can see what you are doing. And are yoiu sure that
"12 some text 3 7"
. . . actually gives 22 by any straightforward means?