.4. • Enter the code
// Function prototype. Some compilers absolutely insist that function
// prototype(s) are present
void blah2(int *i);
// ===========================================================
// Function blah2()
//
// This takes a reference to a value i, increments it and displays it
//
// Returns the calculated voltage.
// ===========================================================
void blah2(int *i)
{
printf("In function: the value of *i is %d\n", *i);
(*i)++; // Equivalent to *i = *i + 1;
printf("In function: the value of *i after increment is %d\n\n", *i);
}
int main(int argc, char *argv[]) {
int num;
num = 3;
blah2(&num);
printf("In main(): the value of num is %d\n", num);
system("pause");
return 0;
}• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code. Also, comment on the difference between passing parameters to a function by reference and by value.
Using loops and condition statements together, Write a program that calculate the cost of energy for energy units restricted between 0 to 500 kWh for an amount less than $6 000.00 for any Zimbabwean resident customer and any amount and unlimited number of units for a foreign resident customer buying from outside Zimbabwe at a rate of $90.00 to one USD. The tariffs are as follows:
• 0 to 50 kWh cost $2.25
• Above 50 kWh to 100 kWh cost $4.51 / kWh
• Above 100kWh to 200 kWh cost $7.89 / kWh
• Above 200kWh to 300 kWh cost $11.25 / kWh
• Above 300kWh to 400 kWh cost $12.94 / kWh
• Above 400 kWh cost $13.50 / kWh
5.3
Enter the code
void blah(int i)
{
printf("In function: the value of i is %d\n", i);
i++;
printf("In function: the value of i after increment is %d\n\n", i);
}
int main(int argc, char *argv[]) {
int num;
num = 3;
blah(num);
printf("In main(): the value of num is %d\n", num);
system("pause");
return 0;
}• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code.
Complete the array representing the buckets for a bucket sort for the following array. This is done using Integers and the key is the value. The value that you have to enter is the amount of elements in each list. An empty list will have a value of 0. A list with 3 elements will have a value of 3.
4 3 6 4 3 4 5 6 3 5 6 5
0 1 2 3 4 5 6 7 8 9
Blank 1. Fill in the blank, read surrounding text.
Blank 2. Fill in the blank, read surrounding text.
Blank 3. Fill in the blank, read surrounding text.
Blank 4. Fill in the blank, read surrounding text.
Blank 5. Fill in the blank, read surrounding text.
Blank 6. Fill in the blank, read surrounding text.
Blank 7. Fill in the blank, read surrounding text.
Blank 8. Fill in the blank, read surrounding text.
Blank 9. Fill in the blank, read surrounding text.
Blank 10. Fill in the blank, read surrounding text.
When using the Quick sort on the following array Complete the index of the following.
pivot: Blank 1. Fill in the blank, read surrounding text.
Low: Blank 2. Fill in the blank, read surrounding text.
High: Blank 3. Fill in the blank, read surrounding text.
The indexes of the first swap low = Blank 4. Fill in the blank, read surrounding text.
high = Blank 5. Fill in the blank, read surrounding text.
The index of the pivot that is returned. Blank 6. Fill in the blank, read surrounding text.
3 8 7 6 7 2 4 1 5
Choose the correct answer
1. Which of the following is a valid prototype for a function that accepts an integer argument and
returns a double value?
a. int function (double);
b. int function (double)
c. double function (int);
d. double function (int)
Study the function header below:
double getResults(double fN, double sN)
2. Which of the following is a valid function prototype for the header?
a. getResults(double firstnum1, double num2);
b. double (double num1, double num2);
c. double getResults(double, double);
d. results = getResults(num1, num2);
3. What value is returned by the following return statement?
int x = 5;
return x / 2;
a. 2
b. 2.5
c. 2.1
d. nothing
What array will best fit this array after three steps of the insertion sort.
6 8 9 1 4 2 5 7 3 0
A. [1,2,4,6,8,9,5,7,3,0]
B. [1,6,8,9,4,2,5,7,3,0]
C. [1,2,4,5,6,7,8,9,3,0]
D. [1,4,6,8,9,2,5,7,3,0]
What array will best fit this array after seven passes of the bubble sort.
5 7 9 1 4 2 6 8 3 0
A. [1,2,0,3,4,5,6,7,8,9]
B. [1,2,4,5,3,0,6,7,8,9]
C. [1,4,2,5,6,3,0,7,8,9]
D. [4,1,6,2,5,7,3,0,8,9]
Choose the correct answer
1. A void function _____.
a. contains no statements
b. requires no parameters
c. returns nothing
d. has no name
2. The value used in a functions’ return statement must _____.
a. be numeric
b. be a variable
c. match the data type used before the method name in the header
d. all of the above
3. When a function definition appears above the main () function, you must have a (n) ____ above the
main () function.
a. argument
b. value parameter
c. prototype
d. none of the above
The system has been running for five years now. Yesterday, the government banking watchdog approached you to ask some questions about two suspicious transactions on your system that look like criminal money laundering.You have been told that each unreported transaction will result in a fine of $15,000.The Primacy of the Public Interest You will place the interests of the public above those of personal, business or sectional interests 2. The Enhancement of Quality of Life You will strive to enhance the quality of life of those affected by your work.3.Honesty You will be honest in your representation of skills, knowledge, services and products.4.Competence You will work competently and diligently for your stakeholders.5.Professional Development You will enhance your own professional development, and that of your staff.6.Professionalism You will enhance the integrity of the ACS and the respect of its members for each other.Explain any relevant legal considerations and how they specificall apply in this scenario