Tuesday, July 9, 2019

c interview question 21

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i=0,k=3;
    i+=func(k);
    i+=func(k);
    i+=func(k);
    printf("%d\n",i);
    return 0;
}

func(int k)
{
    static int m=2;
    m=m+k;
    return m;
}

output::
24


explanation:
1st->k=3,m=5,i=5
2nd->k=3,m=8,i=13
3rd->k=3,m=11,i=24

No comments:

Post a Comment

python class topic video