Get an array and store the squares of each of the element in the array in the same index.
For example:
If the input array is
1 2 3 4 5 6
Then the resultant array is
1 4 9 16 25 36
Implementation:
For example:
If the input array is
1 2 3 4 5 6
Then the resultant array is
1 4 9 16 25 36
Implementation:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
 int i,*a,n,*b;
 
 /* Get the number of elements of the array */
 scanf("%d",&n);
 
 /* allocate memory for n integers and store the initial address in a */
 a=(int*)malloc(sizeof(int)*n);
 
 /* allocate memory for n integers and store the initial address in b */
 b=(int*)malloc(sizeof(int)*n);
 
 /* Get the elements of the array a */
 for(i=0;i<n;i++)
  scanf("%d",(a+i));
 
 /* storing their squares in another array */
 for(i=0;i<n;i++)
  *(b+i)=*(a+i) * *(a+i);
 
 /* printing the squares */
 for(i=0;i<n;i++)
  printf("%d ",*(b+i));
  
 return 0;
}