Example 4 ------------------------------------------------- #include using namespace std; void swap(int &x, int &y){ int temp; temp = x; x = y; y = temp; } int main(){ int a, b; cout << "a="; cin >> a; cout << "b="; cin >> b; swap(a,b); cout << "a="<< a << endl << "b="< using namespace std; void upper(string &word){ int i; for(i=0;i='a'&&word[i]<='z') word[i]=word[i]-('a'-'A'); } int main(){ string word; cout<<"Enter a word: "; cin>>word; upper(word); cout << "word=" << word; return 0; } Example 6 ------------------------------------------------- #include using namespace std; void input(int &n, int &i){ do{ cout << "Input an index: "; cin >> i; }while(i<0||i>=10); cout << "Input new value: "; cin >> n; } void update(int n, int i, int *nums){ nums[i]=n; } void printarray(int *nums){ int i; for(i=0;i<10;i++) cout << nums[i] << " "; cout << endl; } int main(){ int nums[10]={1,3,5,7,9,11,13,15,17,19}; int n, i; input(n,i); update(n,i,nums); printarray(nums); return 0; } Example 7 --------------------------------------------------- #include using namespace std; void printarray(int b[][5]){ int i, j; for(i=0;i<5;i++){ for(j=0;j<5;j++) cout << b[i][j] << " "; cout << endl; } } int main(){ int b[5][5]={{0, 1, 2, 3, 4}, {1, 2, 3, 4, 5}, {2, 3, 4, 5, 6}, {3, 4, 5, 6, 7}, {4, 5, 6, 7, 8}}; printarray(b); return 0; }