char c = 'T', d = 'S';
char *p1 = &c;
char *p2 = &d;
char *p3;
Assume further that the address of c is 6940, the address of d is 9772, and the address of e is 2224. What will be printed when the following statements are executed sequentially?
After these statements, which of the following statements will change the value of i to 75?
* k = 75;
* *k = 75;
* p = 75;
* *p = 75;
* Two or more of the answers will change i to 75.
3. Explain the error.
char c = 'A';
double *p = &c;
4. Give the value of the left-hand side variable in each assignment statement. Assume the lines are executed sequentially. Assume the address of the blocks array is 4434.
For the following functions, use the pointer notation ONLY. Do NOT use the array index [] notation.
1. Write a piece of code which prints the characters in a cstring in a reverse order.
char s[10] = "abcde";
char* cptr;
// WRITE YOUR CODE HERE
2. Write a function countEven(int*, int) which receives an integer array and its size, and returns the number of even numbers in the array.
3. Write a function that returns a pointer to the maximum value of an array of double's. If the array is empty, return NULL.
double* maximum(double* a, int size);
4. Write a function myStrLen(char*) which returns the length of the parameter cstring. Write the function without using the C++ function strlen.
5. Write a function contains(char*, char) which returns true if the 1st parameter cstring contains the 2nd parameter char, or false otherwise.
6. Write a function revString(char*) which reverses the parameter cstring. The function returns nothing. You may use C++ string handling functions in <cstring> in the function if you wish.
int main()
{
char s[10] = "abcde";
revString(s); // call the function
return 0;
}
void revtString(char* ptr)
{
// WRITE YOUR CODE HERE
}