Is my code right? (Arrays, pointers and strings)


Using (Microsoft Visual Studio C++ 6.0) software, follow the sample output to write and run a program that uses two functions called createand print. The function createwill ask the user to enter the size n of an array a andits items to create it. Whereas the function print will print the created array a.
The prototypes of the functions are:
voidcreate(int*&a, int&n);
void print(int *a, int n);


Sample Output (1):
Enter the size of the array: 4
Enter 4items in the array, one per line:
44
77
22
88
The created array is:
44 77 22 88


Sample Output (2):
Enter the size of the array: 2
Enter 2 items in the array, one per line:
3
9
The created array is:
3 9


---------------------------------------------------------------------


#include<iostream>
using name space std;

void create(int*&a, int&n);
void print(int *a, int n);


int main()
{


cout<<"Enter"<<create(a,n)<<"items in the array, one per line:"<<endl;

for(int i=0;i<n;i++)
cin>>a[i];


return 0;
}

void create(int*&a, int&n)
{

int a[100];
int n;
cout<<"Enter the size of the array: ";
cin>>n;



}

void print(int *a, int n)
{


cout<<"The created array is: "<<a[n]<<endl;




}
Did you even tested your code? Because it seems you simple haven't. A hint, use code tags, such thing exists for such purpose.
Topic archived. No new replies allowed.