Note that this statement will assign the same address to all four variables; there's only one call to malloc.
If you want to allocate four different blocks of memory, I'm not aware of any such shortcut. Either allocate them all separately, or for more compact code, put your pointers in an array and allocate them in a loop.
if it assigns same address to all the four variables then how can i proceed with it
The point is you can't, not if you want four separately allocated blocks. We've shown you this construction because it does do something, and it's important to understand so you don't use it incorrectly.
it will somehow delete the values stroed to previous variable while i assign values to the new one,isnt it?
That's not what happens, if I understand your question correctly.
p = q = r = n = (int*)malloc(20 * sizeof(int));
is essentially equivalent to
n = (int*)malloc(20 * sizeof(int));
r = n;
q = r;
p = q;
So there's only one actual call to malloc that happens, and nothing is "deleted."
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...