493 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++ ;
}

2 Answers

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

0 votes
0 votes
0 answers
1
Na462 asked Aug 22, 2018
469 views
What will be output ?A. Abnormal Termination.B. Infinite loopC. Output wil be 65536D. NoneAns. D
2 votes
2 votes
2 answers
2
atulcse asked Jan 15, 2022
661 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...
0 votes
0 votes
0 answers
4
srestha asked Mar 7, 2018
581 views
#include<stdio.h int fun1(int x) { x=14; } int fun2(int x) { x=20; } int main() { int(*p)(),m,n; scanf("%d",&m); if(m) p=fun1; else p=fun2; n=(*p)(); printf("%d",n); retu...