Class Examples 7/17/02 Example #1 ---------- #include void wordcopy(char word[], char saveword[], int length); void reverse(char word[], int length); bool equal(char word[], char word2[], int length); void swap(char &a, char &b); void main() { char word[20], saveword[20]; cout << "Enter a word, less than 20 letters long.\n"; cin >> word; int length = strlen(word); wordcopy(word,saveword,length); reverse(word,length); if (equal(word,saveword,length)) cout << "Your word is a palimdrome.\n"; else cout << "Your word is NOT a palindrome.\n"; } // Works similar to strcpy void wordcopy(char word[], char saveword[], int length) { for (int i=0;i #include void readmatrix(int a[][10], ifstream &matrix); void addmatrix(int a[][10], int b[][10], int c[][10], int dim); void transpose(int a[][10], int dim); void printmatrix(int a[][10], int dim); void swap(int &a, int &b); void main() { ifstream file1, file2; int matrix1[10][10], matrix2[10][10], matrix3[10][10]; // Read matrices from a file file1.open("m1.txt"); file2.open("m2.txt"); readmatrix(matrix1,file1); readmatrix(matrix2,file2); file1.close(); file2.close(); // Add the two matrices and transpose the sum matrix. addmatrix(matrix1,matrix2,matrix3,10); printmatrix(matrix3,10); cout << endl; transpose(matrix3,10); printmatrix(matrix3,10); } void addmatrix(int a[][10], int b[][10], int c[][10], int dim) { int i,j; for (i=0;i> a[i][j]; } void swap(int &a, int &b) { int temp = a; a = b; b = temp; }