please help me to write a program in c++ to find sum of first and last digits of any number

Recommended Answers

All 3 Replies

have you written some code?

Break the problem down into small tasks.

First, you need to find a way to get the first digit and the last digit.

There are many different ways you could get these digits.

One way might be to convert the number into a string. Once you have the string, there are several ways you can get the first and last character.

Convert those characters representing the first and last digit to an int.

Once you have those digits, simply add them together.

please help me to write a program in c++ to find sum of first and last digits of any number

/ and % can come handy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.