Problem:
다음 C 프로그램을 C++ 프로그램으로 수정하여 실행하라. 이 프로그램의 Execution Result는 Exercise Problem 11과 같다.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <stdio.h> int sum(); int main() { int n=0; printf("끝 수를 입력하세요>>"); scanf("%d", &n); printf("1에서 %d까지의 합은 %d 입니다.\n", n, sum(1,n)); return 0; } int sum(int a, int b) { int k, res=0; for(k=a; k<=b; k++){ res += k; } return res; } |
2020/02/28 - [C++/명품 C++ programming] - 명품 C++ programming Exercise Problem 2장 11번
[명품 C++ programming Exercise Problem 2장 11번
Problem: 다음 C 프로그램을 C++ 프로그램으로 수정하여 실행하라. 1 2 3 4 5 6 7 8 9 10 11 12 #include int main() { int k, n=0; int sum=0; printf("끝 수를 입력하세요>>"); scanf("%d", &n); for(k=..
sobamemil.tistory.com](https://sobamemil.tistory.com/37)
Objective & Hints:
C++ Programming에 대한 전반적인 이해
Execution Result:

Code:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include |
Explanation:
C++ 에서는 Function Overloading이 가능하기 때문에 함수의 원형 선언시에 매개 변수까지 모두 동일하게 선언하여야 합니다.