15,879,613 members
See more:
a program which takes input from user at rum tym..
like this
enter the string : abc1234f
and program must do calculations as ab+c1+23+4f
and return the result in two characters
Posted
Richard MacCutchan 17-Oct-14 4:44am
This is your third question on this subject, and you have been given some answers. It's up to you to go and try them.

## Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

## Solution 2

That's pretty easy, you have to:
1. initialize you checksum with `0`, say `chk=0;`
2. Take two characters at time from the input string, e.g. `"ab"`
3. Convert the two characters to a `unsigned char`, say `u` using strtoul[^] with base parameter set to `16` (hexadecimal number)
4. sum the obtained` unsigned char` to the checksum: `chk += u;`
5. Go to point 2 unless the string is completed

It is worth nothing:
• The sum on `unsigned char` discards any carry (as required by checksum algorithm)
• You may also merge steps 2,3 possibly using your own hand crafted two-hex-characters-to-byte function