Which of the following statements creates a pointer variable p and initialises i
ID: 3854779 • Letter: W
Question
Which of the following statements creates a pointer variable p and initialises it to the address of an integer x? a. int * p = &x;: b. int & p = &x;: c. int% p = &x;: d. int&p; = *x: e. None of the above. Which of the following statements about pointer initialization is true a. Pointers can only point to constants b. Pointers can only be initialized to null pointers c. The data variable must be declared before it can be used for pointer initialization. d. Pointers are automatically set to null by the compiler. e. To initialize a pointer to the address of a variable, the variable's identifier is suffixed with the indirection operator(*) Which of the following statements declares a function with a pointer variable as a parameter? a. void fun (int ptr): b. void fun ( ptr): c. void fun (int ptr): d. void fun (int& ptr): e. void fun (int* ptr): Which of the following statements passes a pointer to a variable to a function? a. fun (&x;): b. fun (*x): c. fun (int &x;): d. fun (int* x): e. fun (int *x): Which of the following statements about pointer use in functions is false? a. Passing a pointer to a function allows the function to change the value in the called function. b. Pointers can only be passed: they cannot be returned c. To pass an address from the calling function we use the ampersand operator (&) in the call d. To change the value of the data in the calling function, we use the asterisk operator (*) in the called function. e. Passing pointers to a function allows upward communication.Explanation / Answer
34)answer is:a)int* p=&x;
A pointer is a variable that stores a address of a memory. Pointers are used to store the addresses of other variables.data type of a pointer must be same as the data type of a variable to which the pointer variable is pointing.
the c programming example that creates a pointer variable p and initializes it to the address of an integer x.
#include<stdio.h>
int main()
{
int x;
int* p=&x;
printf("the address of pointer p is:");
printf("%u",p);
}
the output is:the address of pointer p is:37814044
35) answer is e)To initialize a pointer to the address of a variable,the variable's identifier is suffixed with the indirection operator(*).
pointer initialization:pointer initialization is the process of assigning address of a variable to pointer variable.
c programming example to initialize a pointer variable is
#include<stdio.h>
int main()
{
printf("%u",a);
printf("%u",ptr)
}
36)answer is e)void fun(int* ptr);
A function’s name can also be used to get functions’ address.
37)answer is d)fun(int* x);
fun(int* x); is a statement that passes a a pointer to a variable to a function.
38)answer is d)To pass an address from the calling function we use ampersand operator (&) in the call is a false statement about pointer use in functions.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.