C++
[C++] 011 함수
qkrwngus
2021. 1. 24. 12:41
Desc :
어떤 목적을 이유로 구현하는 코드 집합
-> 소스 코드 가독성도 높아지고 유지보수도 수월해짐
자료형 함수이름(인자,,)
{
~~~
return 반환값;
}
Source Code :
#include <iostream>
using namespace std;
void Minus(const int x, const int y) // 인자 값을 변하지 않도록 const로 선언
{
cout << "x - y = " << x - y << endl;
}
int Plus(const int x, const int y)
{
return x + y;
}
int main()
{
Minus(10, 5);
cout << "x + y = " << Plus(8, 2) << endl;
return 0;
}
Result :