How abt this??

#include<stdio.h>
#include<conio.h>
void checkStack(int i)
{
     if(i!=0)
     {
       printf("%d in %u address space\n",i,&i);
       checkStack(i-1);
     }

}
int main()
{
    int i=10;
    checkStack(i);
    getch();
    return 0;
}


Looking at the address in the output terminal we can get the ans...

On 12/15/10, Ankur Khurana <ankur.kkhur...@gmail.com> wrote:
> mine did same job :)
>
> On Wed, Dec 15, 2010 at 12:41 AM, Anand <anandut2...@gmail.com> wrote:
>> Below logic should tell us about the Machine Stack. let me know in case I
>> am
>> missing something.
>>
>> void check_for_stack(int a, int b)
>>
>> {
>>   unsigned int addr_1, addr_2;
>>   printf("%u %u\n", &a, &b);
>>
>>   printf("0x%x 0x%x\n", &a, &b);
>>
>>   if(&a > &b)
>>   {
>>
>>     printf("Machine Stack grows UP: Address keep decreasing");
>>   }
>>   else
>>
>>   {
>>     printf("Machine stack grows down: Address Keep increasing");
>>   }
>>
>> }
>> main()
>> {
>>   int a,b;
>>
>>   check_for_stack(a, b);
>> }
>> http://codepad.org/XGAbghDz
>>
>> On Tue, Dec 14, 2010 at 11:02 AM, bittu <shashank7andr...@gmail.com>
>> wrote:
>>>
>>> How would you find out if a machine’s stack grows up or down in
>>> memory?
>>> can any one xplain wid program..
>>>
>>>
>>> Regards
>>> Shashank Mani
>>> BIT Mesra
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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.

Reply via email to