(i) Write a function that returns the cube of the integer passed to it. For example cube(2) will
return 8 and
cube(3) will return 27.
Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:
vi) float calculateSquare(float number) { return number * number; }
Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:
(v) void theProduct() { int a; int b; int c; int result; cout << “Enter three integers “ << endl; cin >> a >> b >> c; result = a * b * c; cout << “Result is “ << result << endl; return result; }
Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:
(iv) void aFunction(float a) { float a; cout << a << endl; }
Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:
(iii) int computeProd(int n) { if (n == 0) return 0; else } n * computeProd(n – 1)
Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:
(ii) int sum(int x, int y) { int result; result = x + y; }
Find the error(s) in each of the following program segments and explain how the error(s) can be corrected: (i) int function1() { cout << "Inside function function1 " <<
endl; int function2() { cout << "Inside function function1 " << endl; } }
Write function headers for the functions described below:
(iv) The function countChar returns the number of occurrences of a character in a string, both provided as parameters
Write function headers for the functions described below:
(iii) The function time inputs seconds, minutes and hours and returns them as parameters to its calling function.
Write function headers for the functions described below: (ii) The function mult has two floating point numbers as parameters and returns the result of multiplying them.