In: Computer Science
In C++
Create a dynamic array of 100 integer values named myNums. Use a pointer variable (like ptr) which points to this array. Use this pointer variable to initialize the myNums array from 2 to 200 and then display the array elements. Delete the dynamic array myNums at the end. You just need to write part of the program.
#include <stdio.h>
int main()
{
int myNums = (int*)malloc(100 * sizeof(int));
int *ptr=myNums;
ptr[0]=100;
for(int i=2;i<=200;i++)
ptr[i]=i;
for(int i=2;i<=200;i++)
printf("%d ",ptr[i]);
return 0;
}
DON'T FORGET TO HIT LIKE.
THANKS BY HEART.