@Alam: Can u mail tat revised code On 3 August 2011 11:54, Arshad Alam <alam3...@gmail.com> wrote:
> > @Subramanian, I made the changes what you have told, it is running fine,not > giving any warning or error but output is not desirable > > > On Wed, Aug 3, 2011 at 11:41 AM, Thavasi Subramanian <sktthav...@gmail.com > > wrote: > >> Here take is a pointer local to fn main() and array3[10] is local to fn >> modify. So array3's entire locations are not visible to main(). >> "return array3" will retun only the reference of the first element of the >> array. >> So the pointer will store only one value 3(the first value in array3) in >> address "take". >> >> The problem here is the scope of array3. If you declare array3 as a global >> variable then you will get what you are in need of. >> >> >> On 3 August 2011 10:57, Arshad Alam <alam3...@gmail.com> wrote: >> >>> WHY THERE IS ERROR AT THE "BOLD LINE" THAT IS L-VALUE REQUIRED >>> >>> /* >>> Write a program which performs the following tasks: >>> - initialize an integer array of 10 elements in main( ) >>> - pass the entire array to a function modify( ) >>> - in modify( ) multiply each element of array by 3 >>> - return the control to main( ) and print the new array elements in main( >>> ) >>> */ >>> >>> #include<stdio.h> >>> #include<conio.h> >>> void main() >>> { >>> clrscr(); >>> int take[10],i; >>> int array1[10]={1,2,3,4,5,6,7,8,9,10}; >>> int* modify(int*); >>> *take=modify(array1);* >>> for(i=0;i<10;i++) >>> printf("%d ",take[i]); >>> getch(); >>> } >>> >>> >>> int* modify(int* array2) >>> { >>> int i; >>> int array3[10]; >>> for(i=0;i<10;i++) >>> { >>> array3[i]=3*array2[i]; >>> // printf(" %d",array3[i]); >>> } >>> return array3; >>> } >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Thavasi >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thavasi -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.