Question: 1. Write function headers (not the bodies) for the following functions: (a) Return the corresponding decimal number, given a hex number; (b) Display a message
1. Write function headers (not the bodies) for the following functions:
(a) Return the corresponding decimal number, given a hex number;
(b) Display a message a specified number of times;
(c) Test if an integer is a palindrome, return true if it is;
(d) Find the number of occurrences of a specified number in an integer array;
(e) Sort an array.
2. Write C++ statements to do the following:
(a) Declare an array double_array to hold 8 double values;
(b) Assign value 10.9 to the first element in the array double_array;
(c) Write a loop that computes the sum of all elements in the array double_array;
(d) Write a loop that finds the minimum element in the array double_array;
(e) Use an array initializer to declare an int array int_array with initial values 1, 2,3, 5, 8;
3. Answer the following questions about functions and arrays:
(a) When passing arguments to a function, what is pass-by-value? What is pass-byreference?
(b) What is the difference between passing the values of variables of primitive data
types and passing arrays to a function?
(c) How do you prevent the array from being modified accidentally in a function
when this array is passed to the function as an argument?
(d) What is the array index type? What is the range of the index for an array declared
by the statement int list[10]?
(e) Can we change the capacity of an array after this array is declared? Does the
compiler show us error messages or warning if we use an index which is out of the range to access an element of array?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
