All Exams Test series for 1 year @ ₹349 only
Question

Which of the following expression will delete the entire array pointed to by q?

The correct answer is

delete[ ] q;

Therefore, the correct way to deallocate this memory is by using the delete[] operator followed by the pointer. delete[ ] q; - This is the correct syntax in C++ for deallocating memory that was allocated using new[] .

Was this answer helpful?

Important Questions from Array

  1. Consider the following C program segment.

    #include <stdio.h>

    int main()
    {
      char s1[7] = "1234";
        char *p;

        p = s1 + 2;
        *p = '0';

        printf("%s", s1);

        return 0;
    }

    What will be printed by the program?
  2. #include <stdio.h>
    
    void foo(int *p, int x){
        *p = x;
    }
    
    int main(){
        int *z;
        int a = 20, b = 25;
        z = &a;
        foo(z, b);
        printf("%d", a);
        return 0;
    }
    
    The output of the given C program is __________. (Answer in integer)
  3. Consider an array $A$ of integers of size $n$. The indices of $A$ run from 1 to $n$. An algorithm is to be designed to check whether $A$ satisfies the condition given below.

    $\forall i,j \in \{1, \dots, n-1\}$ such that $i > j$, $(A[i + 1] - A[i]) > (A[j + 1] - A[j])$

    Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
  4. What is the output the given C language code snippet? 

    #include<stdio.h>

     int main()

    {

     int x[] = {10,20,30}; 

    int *p = x; 

    p++; 

    printf("%d",*p); 

    return 0; 

    }

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App