This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Variable out of scope and output problem!

Hi guys, I am a new bee in programming for ARM7. I have written the simple following program using for loop to find a factorial of a given number. However to check the result, I have kept the input value static (a = 4), for which factorial should be 24 but somehow the result in the dis assembly window and watch window is not as per expectations. Please help me out. Thank you. The source code is as below:


#include <stdio.h>
#include <LPC21xx.h>
int main()
{
 int a=4,i,fact=a;                                // a is user defined though I've taken it as 4 right now, just to check fact value
for (i=a;i<=1;i--)
{
fact = fact*(i-1);    // fact should be 24 but at this breakpoint I am getting 4!
}
}

Parents Reply Children