Translate

Labels

Wednesday, 12 June 2013

AUTO VARIABLES HAVING SAME NAME IN DIFFERENT BLOCKS

main()
{
auto float f1=20.4;
{
auto float f1=10.8;
{
auto float f1=5.3;
printf("Inner block : f1=%.2f , f1+10=%.2f\n",f1,f1+10);
}
printf("Middle block : f1=%.2f , f1+10=%.2f\n",f1,f1+10);
}
printf("Outer block : f1=%.2f , f1+10=%.2f\n",f1,f1+10);
}


OUTPUT:
Inner block : f1=5.30 , f1+10=15.30
Middle block : f1=10.80 , f1+10=20.80
Outer block : f1=20.40 , f1+10=30.40

No comments: