Skip to content

Instantly share code, notes, and snippets.

@rsmahmud
Created January 6, 2017 18:53
Show Gist options
  • Save rsmahmud/79f339f8e36572fb248fd5c52925a198 to your computer and use it in GitHub Desktop.
Save rsmahmud/79f339f8e36572fb248fd5c52925a198 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
#define MAX 3
int *return_array(int x[], int y[],int count){
int i;
int *z = (int*)malloc(count);
for(i=0; i<count; i++)
z[i] = x[i] * y[i];
return z;
}
int main(){
int i, *c, a[MAX], b[MAX];
printf("Enter %d Elements for Array 1 : ",MAX);
for(i=0; i<MAX; i++)
scanf("%d",&a[i]);
printf("Enter %d Elements for Array 2 : ",MAX);
for(i=0; i<MAX; i++)
scanf("%d",&b[i]);
printf("\nFirst Array : ");
for(i=0; i<MAX; i++)
printf("%3d ",a[i]);
printf("\nSecond Array : ");
for(i=0; i<MAX; i++)
printf("%3d ",b[i]);
c = return_array(a,b,MAX);
printf("\nProduct Array : ");
for(i=0; i<MAX; i++)
printf("%3d ",c[i]);
fflush(stdin);
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment