Question

Which of the following function calls are syntactically correct given the variables and function header below?...

Which of the following function calls are syntactically correct given the variables and function header below? Select all that apply.

int x=0, *ptr1;

ptr1 = &x;

void makeNegative(int *val)

makeNegative(*ptr1);

makeNegative(ptr1);

makeNegative(x);

makeNegative(&x);

Which of the following statements will dynamically allocate memory for an array with 10 elements?

int *ptr = int[10];

int *ptr[10];

int *ptr[10] = new int[10];

Identify all of the smart pointer types.  Select all that apply.

dynamic

weak

unique

shared

Which of the following statements will free memory allocated dynamically for an array of 10 elements?

delete [] ptr;

delete [10] ptr;

ptr = nullptr;

delete ptr[10];

What mathematical operations are permitted on pointer variables? Select all that apply.

addition

division

subtraction

none

multiplication

int *ptr = new int[10];

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1: makeNegative(&x);
as makeNegative() it is expecting address of the variable
Answer 2: int *ptr = new int[10];
Answer 3:weak,unique,shared
Answer 4:delete [] ptr;
Answer 5:subtraction
using that we can find the distance between 2 pointers

Note : If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Which of the following function calls are syntactically correct given the variables and function header below?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 34) Which of the following arithmetic operations is allowed on pointer variables? a. Modulus b. Multiplication...

    34) Which of the following arithmetic operations is allowed on pointer variables? a. Modulus b. Multiplication c. Increment d. Division 35) In a two-dimensional array, the elements are arranged in a table form. True False 36) In C++, which is the proper use of the indirection operator. int *ptr int &ptr int ptr[] None of the above 37) The statement int list[25]; declares list to be an array of 26 components, since the array index starts at 0. True False...

  • Which of these function correctly defines the function g(), which should return a pointer to a...

    Which of these function correctly defines the function g(), which should return a pointer to a dynamically allocated array? a. int g(int size) { int *ptr = new int [size]; return *ptr;} b. int* g (int size) { int data [size]; int *ptr =data; return ptr;} c. int* g(int size) { int *ptr = new int[size]; return ptr;} d.int g(int size { int *ptr = new int [size]; return ptr;} e. int g (int size) { int data[size]; int *ptr...

  • C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(int*...

    C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(int* ptri, int* ptr2) { int *temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap1(int ptri, int ptr2){ int temp; temp = ptri; ptr1 = ptr2; ptr2 = temp; portion void swap2(int *&ptri, int *&ptr2){ int* temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap3(int &ptri, int &ptr2) { int temp; temp = ptr1; ptr1 = ptr2; ptr2 =...

  • Consider the syntactically correct C code below, which is missing a function copy_positive. #include <stdio.h> /*...

    Consider the syntactically correct C code below, which is missing a function copy_positive. #include <stdio.h> /* copy_positive(A, Aout, size) * Given an array A, which will have the provided size, copy all positive * (non-negative/non-zero) elements of A into the provided output array Aout. * Return the size of the resulting array. */ /* (your code from below would be placed here) */ void print_array(int arr[], int n){ for( int i = 0; i < n; i++ ) printf("%d ",...

  • 1. Your project will include the following three files: A header file: dynamicArray.h that includes a...

    1. Your project will include the following three files: A header file: dynamicArray.h that includes a list of function prototypes as enumerated in the next section. An implementation file: dynamicArray.cpp that implements the functions declared in the header file. A test driver file: dynamicArray-main.cpp that includes the main() function so that you can test all the functions you've implemented above. 2. The header file dynamicArray.h will include the following list of functions: constructing a dynamic array of the specified size...

  • In C++ and comment so I UNDERSTAND Implement a class named DynamicArray that has the following...

    In C++ and comment so I UNDERSTAND Implement a class named DynamicArray that has the following members: A pointer to hold a dynamically allocated array, of type int. A member variable to hold the size of the array. A default constructor, which will allocate an array of size 10 A parameterized constructor, which takes a size and use the size to allocate array. A copy constructor, which performs deep copy. A copy assignment operator, which performs deep copy and supports...

  • Malloc function For the prelab assignment and the lab next week use malloc function to allocate...

    Malloc function For the prelab assignment and the lab next week use malloc function to allocate space (to store the string) instead of creating fixed size character array. malloc function allows user to allocate memory (instead of compiler doing it by default) and this gives more control to the user and efficient allocation of the memory space. Example int *ptr ptr=malloc(sizeof(int)*10); In the example above integer pointer ptr is allocated a space of 10 blocks this is same as creating...

  • Write a function, swapSubtrees, that swaps all of the left and right subtrees of a binary...

    Write a function, swapSubtrees, that swaps all of the left and right subtrees of a binary tree. Add this function to the class binaryTreeType and create a program to test this function. #include <iostream> using namespace std; //Definition of the Node template <class elemType> struct nodeType { elemType info; nodeType<elemType> *lLink; nodeType<elemType> *rLink; }; //Definition of the class template <class elemType> class binaryTreeType { public: //Overload the assignment operator. const binaryTreeType<elemType>& operator=(const binaryTreeType<elemType>&) { if (this != &otherTree) //avoid self-copy...

  • plz solve 2 ,4,8,10 " << endl; acement display? Ans: answer= B. answer 2. cu int...

    plz solve 2 ,4,8,10 " << endl; acement display? Ans: answer= B. answer 2. cu int x = 2, y = 1; what will the following cout statement display? Ans: cout << "answer=" < (x || !y ) << endl; A. answer=0 B. answer=1 C. answer=2 D. None of these This code void ActivateBuzzer(int); is c A. to call a function B. function definition (C.)function declaration D. not valid Which option correctly describes the result of the following C/C++ code?...

  • Using C programming

    Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT