100?

2 votes

Consider the following C code:

include <stdio.h>

int fun()

{

static int num=25;

return num--;

}

int main()

{

for(fun( ); fun();fun())

printf("%d", fun( ));

return O;

}

The sum of the values printed by the above program will be

include <stdio.h>

int fun()

{

static int num=25;

return num--;

}

int main()

{

for(fun( ); fun();fun())

printf("%d", fun( ));

return O;

}

The sum of the values printed by the above program will be

0

first time when for loop is executed it become

1. for(fun=25;fun()//here decrement will take place so now value is 24;fun())

printf ("%d",fun() //here decrement will take place so now value is 23)

2. now condition check so value become 22

3 now again for loop for(fun=22;fun() //here decrement will take place so now value is 21; fun())

printf ("%d",fun() //here decrement will take place so now value is 20)

nd so on

1. for(fun=25;fun()//here decrement will take place so now value is 24;fun())

printf ("%d",fun() //here decrement will take place so now value is 23)

2. now condition check so value become 22

3 now again for loop for(fun=22;fun() //here decrement will take place so now value is 21; fun())

printf ("%d",fun() //here decrement will take place so now value is 20)

nd so on

1 vote

It won't do anything , it will have compilation error.

Used : instead of ;

If we consider it without errors , equivalent while loop can be written as :-

fun(); //initialization

while(fun()//termination condition when fun() gets 0) {

print("%d",fun());

fun();

}

which will print :-

2320171411852

Used : instead of ;

If we consider it without errors , equivalent while loop can be written as :-

fun(); //initialization

while(fun()//termination condition when fun() gets 0) {

print("%d",fun());

fun();

}

which will print :-

2320171411852

0