in Programming
373 views
2 votes
2 votes
int i = 0 ;
main( )
{
printf ( "\nmain's i = %d", i ) ;
i++ ;
val( ) ;
printf ( "\nmain's i = %d", i ) ;
val( ) ;
}
val( )
{
i = 100 ;
printf ( "\nval's i = %d", i ) ;
i++ ;
}
in Programming
373 views

1 comment

edited by
0,100,101,100
2
2

2 Answers

2 votes
2 votes
Best answer

....

selected by

1 comment

But this is call by value  not call by address ,so  i think answer should be 0,100,1,101
0
0
0 votes
0 votes

ans i m getting as : 0  100  1  101

int i = 0 ;// i initialized to 0 and it is global
main( )
{
printf ( "\nmain's i = %d", i ) ;// prints global i hence prints 0
i++ ;// global i changes from 0 to 1
val( ) ;// prints 100
printf ( "\nmain's i = %d", i ) ;//prints global i hence prints 1
val( ) ;//again prints 100
}


val( )
{
i = 100 ;//as it is auto variable hence every time code starts executing from here 
printf ( "\nval's i = %d", i ) ;
i++ ;
}

Related questions