Re: [algogeeks] problem with array

2011-08-03 Thread Arshad Alam
@Subramanian--  great man, thanx alot. actually what I does is I had define
array3 inside the main function instead of globally, you had told me to
define array3 globally but by mistake I defined it inside the main function
which was my fault... thanx alot brother.

On Wed, Aug 3, 2011 at 1:36 PM, Thavasi Subramanian wrote:

>
> @Alam, Try this revised code
>
> #include
> #include
> int array3[10];
> main()
> {
> clrscr();
> int *take,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;
> for(i=0;i<10;i++)
> {
> array3[i]=3*array2[i];
>//printf(" %d",array3[i]);
> }
> return array3;
> }
>
>
> On 3 August 2011 13:31, Thavasi Subramanian  wrote:
>
>> @Alam: Can u mail tat revised code
>>
>>
>> On 3 August 2011 11:54, Arshad Alam  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  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
> #include
> 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
>>
>
>
>
> --
> 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.



Re: [algogeeks] problem with array

2011-08-03 Thread Thavasi Subramanian
@Alam, Try this revised code

#include
#include
int array3[10];
main()
{
clrscr();
int *take,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;
for(i=0;i<10;i++)
{
array3[i]=3*array2[i];
   //printf(" %d",array3[i]);
}
return array3;
}


On 3 August 2011 13:31, Thavasi Subramanian  wrote:

> @Alam: Can u mail tat revised code
>
>
> On 3 August 2011 11:54, Arshad Alam  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  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
 #include
 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
>



-- 
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.



Re: [algogeeks] problem with array

2011-08-03 Thread Thavasi Subramanian
@Alam: Can u mail tat revised code

On 3 August 2011 11:54, Arshad Alam  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  > 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  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
>>> #include
>>> 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.



Re: [algogeeks] problem with array

2011-08-02 Thread Arshad Alam
@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
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  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
>> #include
>> 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.



Re: [algogeeks] problem with array

2011-08-02 Thread sagar pareek
here u have taken array "*take*[]"  as constant...change its declaration  to
int* yake;
then it will not give u error

On Wed, Aug 3, 2011 at 11:41 AM, Thavasi Subramanian
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  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
>> #include
>> 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.
>



-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD

-- 
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.



Re: [algogeeks] problem with array

2011-08-02 Thread Thavasi Subramanian
Also take[] cannot be an array... It should be a pointer since function
cannot return more than one value.

On 3 August 2011 11:41, Thavasi Subramanian  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  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
>> #include
>> 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
>



-- 
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.



Re: [algogeeks] problem with array

2011-08-02 Thread Thavasi Subramanian
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  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
> #include
> 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.