Hi friends,
             Run this program u will get the value of ( i = 3 ) if u run in Turbo-C,
 
#include<stdio.h>
 int i=2;
   void main()
 {
   int i=3;
   clrscr();
    {
      int i=10;
       {
  int i=5;
    {
     printf(" %u",*(&i+2));
    }
 }
     }
 }
 
with regards,
   pravin

Arif Ali Saiyed <[EMAIL PROTECTED]> wrote:

> #include<stdio.h>
>
> int i=2;
>   void main()
> {
>    int i=3;
>    {
>      int i=10;
>       {
>         int  i=5;
>           {
>            printf();
>           }
>        }
>     }
> }
>
>what can i write in printf so that the output will give the value of
>i=3;
>       VIVEK

If it is C++ you can use scope resolution operator and print 2
by printing ::i , without scope resolution it will print 5.

If you want to print only three then  may be you can do this

printf("%d",i=3);

It will assign value 3 to ur last defined i=5 and will print.

(i think u forgot to write int before i=10 and i=5 )

if it is C program u can access only  local variable (inner most/near most local tp printf , plz correct me if i ma wrong )

if it is C++ you can access local (inner most) variable as well as global variable using ::operator.

I dont think there is any other ways to access other local variable
which have the same name as the inner most local variable.

plz correct me if i am wrong.

-Arif








To unsubscribe : [EMAIL PROTECTED]




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=315388.5526708.6599542.3001176/D=groups/S=:HM/A=2372354/rand=801662941


Yahoo! Groups Links

Reply via email to