Question: #include #include int main() { int *ptr = (int *)malloc(sizeof(int)*2); int *ptr1 = (int *)malloc(sizeof(int)*2); int i,n1=1,n2=1; //initilize n1 and n2 is 1 in start

#include

#include

int main()

{

int *ptr = (int *)malloc(sizeof(int)*2);

int *ptr1 = (int *)malloc(sizeof(int)*2);

int i,n1=1,n2=1; //initilize n1 and n2 is 1 in start

printf("Entered as many array as you want to add and press q for exit ");//output msg

for(i = 0; i > -1; i++)

{

ptr = realloc(ptr, sizeof(int)*n1);

printf("Enter the value array1[%d]=",i);//output msg

if(scanf("%d", &*(ptr + i))==1)

{

n1=n1+1;

}

else

{

n1=n1-1;

break;

}

}

printf("Enter as many array as you want to add and press q for exit ");//output msg

for(i = 0; i >-1; i++)

{

int ch;

while ( (ch=getchar()) != ' ' && ch !=EOF)

ptr1 = realloc(ptr1,sizeof(int)*n2);

printf("Enter the value array2[%d]=",i);//output msg

if(scanf("%d", &*(ptr1 + i))==1)

{

n2=n2+1;

}

else

{

n2=n2-1;

break;

}

}

for(i = 0; i

{

printf("The position %d =%d and %d ",i,*(ptr + i), *(ptr1 + i));//output msg

}

getchar();

return 0;

}

C PROGRAMMING: Add to this code so that the two arrays are compared and if the arrays arent equal, add to the shorter one. EXAMPLE: #include #include int main() { int *ptr = (int *)malloc(sizeof(int)*2); int *ptr1

arks People Window Help Yout Solve C Solve C Probl cswebdav/pid-1153522-dt-content-rid-11366785.1/courses/D2810-7322/lab9.pdf Strings are arrays of characters(you will need to malloc a 2d array) Break this problem into smaller parts - tackle them one at a time . Problem2 Take two arrays of ints in from the user. Make sure to dynamically allocate them. Compare these two lists to each other, and if you come across an element that is not in the other array, add it to it. Make sure to use realloc to increase the size of the array. Your input doesn't have to be in it's own function, but if you do do so, make sure you pass the pointer by reference and deference accordingly Example input and output: as many numbers as you want for array 1, press q to qu nter the 8th elenent: 1 Enter the 1th element: 2 nter the 2th elenent: 3 nter the 3th elenent:4 nter the 4th elenent:5 nter the 5 nter the nter the 7th elenent: q Sth element: 6 6th element: 7 nter as many numbers as you want for array 1, press q to quit ter the 8th elenent: 9 nter the 1th elenent: 12 nter the 2th elenent: 15 nter the 3th elenent: q osition e is 1 and 9 ositton1 1s 2 and 12 os it ton 2 is 3 and 15 osition3 is4 and 1 sLtLon 4 1s 5 and 2 LtLon 5 is 6 and sition 6 1 7 and4 sttion 7 1s 9 and 5 SSTLOn8 1S 12 and 6 15 and 7 13.00 Q Search Yahoo! 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!