c++ questions need help QUESTION 1 Given the following code, what is the value of *ptr? int var = 5; int *ptr = &var; int *myptr = ptr; *ptr = -8; var = 0; *myptr = 2;
| a. |
2 |
|
| b. |
-8 |
|
| c. |
5 |
|
| d. |
0 |
QUESTION 2
Given the following code, what is the value of ptr+1?
int arr[3] = {0, 0, 0};
int *ptr = arr;
*ptr = 8;
| a. |
9 |
|
| b. |
undefined |
|
| c. |
the address of arr[0] |
|
| d. |
the address of arr[1] |
QUESTION 3
Given the following code, what is the type of the expression &ptr? int *ptr;
| a. |
not a valid expression |
|
| b. |
int |
|
| c. |
pointer to an int |
|
| d. |
pointer to a pointer to an int |
QUESTION 1 a. 2 QUESTION 2 d. the address of arr[1] QUESTION 3 d. pointer to a pointer to an int
c++ questions need help QUESTION 1 Given the following code, what is the value of *ptr?...
QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p %p", *r, a); A. Different memory addresses printed B. 1 2 C. Same memory address printed twice D. 1 1 2 points QUESTION 10 What will be the output of following code snippet? int arr[4] = {1, 2, 3, 4}; int *p; p = arr + 3; *p = 5; printf("%d\n", arr[3]); A....
1.What will the following statement output? cout << &num1; A)None of these B)the value stored in the variable named num1 C)the number 1 D)the memory address of the variable named num1 E)the string &num1 2. What will the following code output? int number = 888; int *var = &number; cout << var << endl; A)the address of number B)an asterisk followed by 8888 C)8888 D)an asterisk followed by the address of number 3. Assuming ptr is a pointer variable, what...
Consider the following code snippet. What will be printed by *ptr and ptr after the lines shown. Explain with screenshots. int a[4] = { 8, 3, 5, 6}; int *ptr = a; ptr ++;
Question 17 2 pts A pointer is: A keyword used to create variables A variable that stores address of an instruction A variable that stores address of other variable A macro defined as a preprocessor directive. 2 pts Question 18 The operator used to get value at address stored in a pointer variable is: O& && O II Question 19 2 pts In the following code what is 'P: typedef char *charp; const charp P; Pis a constant Pis a...
Question 27 The following statement ________. cin >> *num3; stores the keyboard input in the variable num3 stores the keyboard input into the pointer num3 is illegal in C++ stores the keyboard input into the variable pointed to by num3 None of these Question 28 The following statement ________. int *ptr = new int; results in a compiler error assigns an integer less than 32767 to the variable ptr assigns an address to the variable ptr creates a new pointer...
How do you do the commented part of this question (its the part that is bolded)? #include <stdio.h> #include <string.h> main(){ int *p, in=10; p = ∈ printf("%d\n", *p ); char arr[]="hello"; char *ptr = arr; // different ways to pass the array, at "pointer" level. printf("%s %s %s\n", arr, &arr[0], ptr); //different ways to access arr[0] printf("%c %c %c %c\n", arr[0], *ptr, *arr, ptr[0]); //different ways to access arr[1] printf("%c %c %c %c\n", arr[1], *(ptr+1), *(arr+1), ptr[1] ); //different...
What will the following code printout? void Function(int *ptr) { *ptr = 11; } // In Main... int values[] = {4, 10, 6, 12, 8, 14}; int *p = &values[4]; Function(p); for(int i = 2; i < 5; i++) cout << values[i] << ' '; a) 6 12 8 14 b) 6 12 8 c) 4 10 6 11 8 14 d) 6 12 11 e) 6 12 11 14 I know the answer is D, but I do not...
Given the following code segment, int x = 20; int y = 7; what is the data type of the value of the expression (x % y) ? (3 points) Question 1 options: 1) int 2) double 3) numeric 4) Error: possible loss of precision 5) Unable to be determined Question 2 (3 points) Given the following code segment, double x = 42.3; double y = 11.7; what is the data type of the value of the expression (x %...
Given the following: int xyz[9] = {88, 99, 22, 15}; int *ptr = xyz; and assuming that xyz is stored at memory address 2500, what is the value of each of the following? xyz[0] xyz[2] xyz[4] xyz[9] &xyz[0] ptr *ptr *ptr+1 *(ptr+1)
Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...