#include <iostream> using namespace std; int main(){ //求兩數的和? int a,b,s; cout<<"請你輸入兩個整型的數字:"<<endl; cin>>a>>b; int sum(int x ,int y); s=sum(a,b);//實際參數 ,代表具體數值,在()當中 cout<<"The sum of a and b is:"<<sum<<endl; //system("pause"); return 0; } //首先確定函數是否需要返回值?需要返回值的話要寫返回值類型 如果不需要返回值則寫void int sum(int x ,int y){//形式參數 //變量的生命周期 接收實際參數的賦值 int x=a,int y=b; return x+y; }

