******************************************** #include int main() { int a, n, t; float p; cout <<"enter a, n and t" << endl; cin >> a >> n >> t; p = 2/3*(a + n)^t; cout <<"P is " << p << endl; } ******************************************** Arrays of characters - strings ------------------------------ write a program which allows the user to enter a four (4) letter word. the individual characters making up the word should be stored in individual elements of an array. the program should print the entered word forwards and backwards on the screen. ============================= #include void main(void) { char word[4]; //an array of char int i; //index cout <<"Enter four letters" << endl;; i = 0; while (i < 4) { cin >> word[i]; i ++; } //print forwards cout <<"\nForwards..."; i = 0; while (i < 4) { cout << word[i]; i ++; } //print backwards cout <<"\nBackwards..."; i = 3; while (i >= 0) { cout << word[i]; i --; } cout << endl; } =============================== the word string refers to a sequential array of characters such as: the cat sat on the mat strings are used for messages, words, sentences and so on, any sequence of characters, and are very commonly found in computer programs. you have already used literal strings in your programs, like this: cout <<"Have a nice day";, why are strings different---: when we store characters in a string(an array of characters) a special character is used as a sentinel to signal the end of array. this special character is called the null char. it is non_printable and so can safely be used to signify the_end_of_sting. the code of zero, in order to write it in a program, we use the syntax: '\o' we could store the message "hello" like this: message[o] = 'h'; message[1] = 'e'; message[2] = 'l'; message[3] = 'l'; message[4] = 'o'; message[5] = '\o'; =============================== sample string program #include #include void main(void) { char first_name[20], last_name[40], full_name[70]; cout <<"enter your first name\n"; cin >> first_name; cout <<"enter your last name\n"; cin >> last_name; strcpy(full_name, last_name); strcat(full_name, ","); strcat(full_name, first_name); int len = strlen(full_name); cout <<"your full name is " << full_name << endl; cout <<"which contains " << len << " characters" << endl; } =============================== char sentace[50]; cin >> sentance; the cat sat this problem can be overcome by using the member function getline() to read strings which contain spaces. ex: chat sentence[50]; cin.getline(sentence, 50); ******homework ******-------- 1. write a program which manipulates an array of 7 integers according to the following rules: * the first element is 47; * the last element is 65; * the second element is one more than the last element * the second to the last element is 13 less than the first element * the the 4th element is the sum of the first two and the last two elements * the 3rd and 5th elements are both zero 2. write a function which accepts a string as a parameter and returns the number of vowels in it. volers are A, E, I, O AND U, and their lower case equivalents.