Gaurav Kochhar

Gaurav Kochhar

  • NA
  • 2
  • 540

My C language Basic Coding Problem.

Jul 23 2018 4:39 AM
//I am doing this with the pointer as:
 
#include <stdio.h>
#include <stdlib.h>
int *fun1(int ar[])
{
return ar;
}
int main()
{
int n,i,arr[10],*d;
printf("Enter the element of array:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
printf("Array you get from the function is:");
d=fun1(arr);
for(i=0;i<n;i++)
{
printf("%d\t",*(d+i));
}
return 0;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BUT Only with Array i am not doing same operation please give me solution.
 
 
#include <stdio.h>
#include <stdlib.h>
int * fun1(int ar[])
{
return ar;
}
int main()
{
int n,i,arr[10],d[10];
printf("Enter the element of array:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
printf("Array you get from the function is:");
d=fun1(arr);
for(i=0;i<n;i++)
{
printf("%d\t",(d+i));
}
return 0;
}