Write C statements in main as indicated belowDeclare a point

Write C++ statements in main() as indicated below.//Declare a pointer called p that is capable of pointing to int-type numbers//Create a dynamic array of 10 integers and store its (base) address in the pointer p that you had//declared above//If p points to a non-NULL address, then initialize all array elements to the value 0. If p points to a NULL//address, then return from main() with a return value 1.//Remove completely from memory, the above dynamic array

Solution

#include<bits/stdc++.h>

using namespace std;

int main()

{

int* p; //Pointer to int

p=new int[10]; //dynamic array of 10

if(p!=NULL)

{

memset(p,0,sizeof(p)); //set all elements to 0

}

else

{

return 1;

}

delete []p; //delete dynamic array

}

 Write C++ statements in main() as indicated below.//Declare a pointer called p that is capable of pointing to int-type numbers//Create a dynamic array of 10 in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site