Hi All,
Below is a code which I am not understand.
#include<stdio.h>
int main(int argc, char *argv[])
{
int num;
printf("\n Number: " );
scanf("%d", &num);
if (num >= 0)
{
int abs = num;
}
else
{
int abs = -num;
}
{
int abs;
printf("\n Values are %d %d", num ,abs);
}
return 0;
}
When I enter a number as 4, the output is Values are 4 4
When I enter a number as -4, the output is Values are -4 4
I am not able to understand how is it able to print the absolute value?. the variable abs defined in the if loop and else loop should have been deallocated after exiting.
Kindly let me know.
Regards, darkie