| | |
Sum of digits
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Sure...
VB Code:
VB Code:
C++ Syntax (Toggle Plain Text)
Function sumFirstLast(number As Integer) As Integer Dim numberString As String numberString = Abs(number) & "" sumFirstLast = Val(Mid(numberString, 1, 1)) + Val(Mid(numberString, Len(numberString), 1)) End Function
what? WHAT?
or, in C++,
C++ Syntax (Toggle Plain Text)
int sumFirstLast( int n ) { char s[32]; return ((n % 10) + (*itoa(n,s,10) - '0')); // itoa converts an int into a string }
![]() |
Similar Threads
- The sum of digits of a number (C)
- Even sum of digits (C++)
- Sum of digits (C)
- Input an Array then Find sum of digits and num of digits (C++)
Other Threads in the C++ Forum
- Previous Thread: Help with error checking code
- Next Thread: Allegro, DirectX or...???
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets





