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();
void main()
{
int i=3;
clrscr();
{
int i=10;
{
int i=5;
{
printf(" %u",*(&i+2));
}
}
}
}
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 | |
|
|
Yahoo! Groups Links
- To reply to this message, go to:
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=3657
Please do not reply to this message via email. (more info)
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmers-Town/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
