Chapter16solutions

# Chapter16solutions - Chapter 16 16.1 int changeToPL(char...

This preview shows pages 1–3. Sign up to view the full content.

Chapter 16 16.1 int changeToPL(char * word) { int i = 1; char first = word[0]; if (first = '\0') return -1; while (word[i] != '\0') word[i - 1] = word [i]; word[i] = first; word[i + 1] = 'a'; word[i + 2] = 'y'; word[i + 3] = '\0'; } 16.2 void RunningSum() { int old, new, sum = 0, count = 0; printf("Number : "); scanf("%d", &old); sum = old; count++; printf("Number: "); scanf("%d", &new); while(old != new) { count++; sum += new; old = new; printf("Number: "); scanf("%d", &new); } printf("%d number were entered and their sum is %d", count, sum); } 16.3 x = 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
16.4 int StringCompare(char stringA[], char stringB[]) { int i = 0; while (stringA[i] != '\0' && stringB[i] != '\0') { /* The call to ToUpper returns the character in uppercase */ if (ToUpper(stringA[i]) < ToUpper(stringB[i])) return 1; else if (ToUpper(stringA[i]) > ToUpper(stringB[i])) return 2; i++; } /* We've reached the end of one or both strings */ if (ToUpper(stringA[i]) == ToUpper(stringB[i])) return 0; else if (ToUpper(stringA[i]) < ToUpper(stringB[i])) return 1; else return 2; } 16.5 void insertionSort(char* list[]) { int unsorted; int sorted; char *unsortedItem; /* This loop iterates from 1 thru MAX_NUMS */
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

Chapter16solutions - Chapter 16 16.1 int changeToPL(char...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online