//============================================================================
// 제출일 : 2005. 3. 12
// 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4
// 연습문제 4-33
//============================================================================
#include <iostream.h>
//using namespace std;
// Prototype Declarations
int addThreeDigits (int num);
int firstDigit (int);
int secondDigit (int);
int thirdDigit (int);
int main()
{
cout << "Enter an integer: ";
int number;
cin >> number;
int sum = addThreeDigits (number);
cout << "\nSum of last three digits is: " << sum;
return 0;
} //main
int addThreeDigits (int number)
{
int result = firstDigit(number) + secondDigit(number) + thirdDigit(number);
return result;
}
int firstDigit(int num)
{
return (num % 10);
}
int secondDigit(int num)
{
int result = (num / 10) % 10;
return result;
}
int thirdDigit(int num)
{
int result = (num /100) % 10;
return result;
}
'Studies > A Structured Approach Using C++' 카테고리의 다른 글
Project 4-39 Temperature convertor : Fathrenheit VS Centigrade 온도변환기 : 화씨 섭씨 (0) | 2008.08.23 |
---|---|
Project 4-38 Compute the interest and print the balance (0) | 2008.08.23 |
Project 4-37 Prepare a payroll earnings statement (0) | 2008.08.23 |
Problem 4-35 print the ceiling, floor, and rounded value of a floating-point number (0) | 2008.08.23 |
Computer Science: A structured approach using C++ (0) | 2008.08.21 |