Given the following code and output, write prototypes and definitions for the Di
ID: 3532673 • Letter: G
Question
Given the following code and output, write prototypes and definitions for the DisplayMe(), IncrementMe() and IsEven() functions:
DisplayMe() should take a single integer argument and return nothing (pass-by-value). It will display the value of the passed argument followed by a newline.
IncrementMe() should take a single integer argument and return nothing (pass-by-reference). The variables passed is incremented by one within the function IncrementMe(). Nothing is displayed on the console when this function runs.
IsEven() should accept a single integer argument (pass-by-value). The function should return a bool with a value reflecting whether or not the values passed in is even (divisible by 2). Nothing is displayed on the screen.
#include <iostream>
using namespace std;
// PROTOTYPES GO HERE
int main() {
int x = 10;
bool y = false;
DisplayMe(x);
IncrementMe(x);
DisplayMe(x);
y = IsEven(x)
y ? cout << "EVEN" << endl : cout << "ODD" << endl;
return 0;
}
PROGRAM OUTPUT
10
11
ODD
Write a statement that declares an integer pointer and aims it at memory address 0x00000000. Begin with the following code:
#include <iostream>
using namespace std;
int main() {
int someInteger = 10;
// YOUR CODE GOES HERE
return 0;
}
PLEASE ANSWER THE TWO QUESTIONS USING THE GIVEN INFORMATION AND CODE.
Explanation / Answer
First part:
http://ideone.com/eZwYrx
Second part:
This will point to the int which is in the address 0x00000000.
int *ptr;
*ptr = 0x00000000;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.