A variable has a number of attributes including but not limited to name, value and type. Please note not every variable has a name. Given the following code, please (1) find total number of variables, and (2) for each of the variables give out the name, type, and value info (if a value is a memory address just write ‘addr’.), e.g. Variable 1: name (cv1), type (int), value (5).
int cppMethod () { //C++ like code
static int cv1 = 5;
double *cv2 = new double (5.0)
bool b = (cv1 == 5);
…
}
Variable 1: name (cv1), type (int), value (5).
Variable 2: name (cv2), type (pointer to double) value(addr)
variable 3: name (b), type (bool(boolean)) value(true)
bool b = (cv1 == 5); == operator checks for eqaulity so cv1==5 means and cv1 holds the value 5 so its return true
If you have any query regarding the answer please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Get Answers For Free
Most questions answered within 1 hours.