Question 1 #include using namespace std; int main(){ string word = "Computer"; int x; while (1) { do { cout << "Array index = "; cin >> x; if ((x < 0) || (x >=word.length())) printf("Out of range\n\n"); } while ((x < 0) || (x >= word.length())); cout << "Content = " << word[x]< using namespace std; int main(){ string sentence = "Sacred Heart Canossian College"; int x, y, i; while (1) { do { cout << "Starting index = "; cin >> x; } while ((x < 0) || (x >= sentence.length())); do { cout << "Length of the substring = "; cin >> y; } while ((y <= 0) || (y >= sentence.length()-x+1)); cout << "Result = "; for (i=x; i using namespace std; int main(){ string sentence; int count=0, i; cout << "Enter a sentence: "; getline (cin,sentence); if (sentence[0] != ' ') count++; for (i=1; i= 'a') && (sentence[i] <= 'z')) sentence[i] = sentence[i] - 'a' + 'A'; cout << sentence << endl; return 0; } Question 4(b) #include using namespace std; int main(){ string sentence; int i; cout << "Enter a sentence: "; getline(cin,sentence); for (i=0; i= 'A') && (sentence[i] <= 'Z')) sentence[i] = sentence[i] + 'a' - 'A'; cout << sentence << endl; return 0; } Question 4(c) #include using namespace std; int main(){ string sentence; int i; cout << "Enter a sentence: "; getline(cin,sentence); if ((sentence[0] >= 'a') && (sentence[0] <= 'z')) sentence[0] = sentence[0] - 'a' + 'A'; for (i=1; i= 'a') && (sentence[i] <= 'z')) sentence[i] = sentence[i] - 'a' + 'A'; else if ((sentence[i-1] != ' ') && (sentence[i] >= 'A') && (sentence[i] <= 'Z')) sentence[i] = sentence[i] - 'A' + 'a'; cout << sentence << endl; return 0; } Question 5 #include using namespace std; int main() { string s, z; char x[100], y[100], temp; int i, len; cout << "Plain text: "; getline(cin,s); len = s.length(); cout << len; for (i=0; i using namespace std; int main() { string email; char no[3]; int number; cout << "class: "; cin >> email; cout << "number: "; cin >> number; if(email[1]>='A'&&email[1]<='Z') email[1]=email[1]+('a'-'A'); no[0] = (char) ('0' + number / 10); no[1] = (char) ('0' + number % 10); no[2] = '\0'; email = email + no + "@shcc.edu.hk"; cout << "email address: " << email; return 0; } Quesiton 7 #include using namespace std; int main() { string x, y, temp; cout << "x: "; cin >> x; cout << "y: "; cin >> y; if (y < x) { temp = x; x = y; y = temp; } cout << "x: " << x << endl; cout << "y: " << y << endl; return 0; }