• retagged by
650 views
0 0 votes
#include <stdio.h>

int counter = 0;

int g(int n) {
    counter++;
    return (n + 10);
}

int f(int n) {
    return g(n * 2);
}

int main() {
    int sum = 0, n;
    for (n = 1; n < 3; n++)
        sum += g(f(n));
    printf("sum = %d, calls = %d\n", sum, counter);
    return 0;
}
 

3 Answers

Position:
Show:

Related questions

8 8 votes
1 1 answer
236
236 views
GO Classes asked Jun 6
236 views
What is the output of the following code?#include <stdio.h void fun() { static int x = 3; int y = 2; x = x + y; y = y + x; printf("%d ", x); } int main() { fun(); fun(); ...
4 4 votes
2 2 answers
308
308 views
GO Classes asked Jun 5
308 views
What is the output of the following code?#include <stdio.h int update(int x) { x = x + 3; return x * 2; } int main() { int a = 4, b; b = update(a); printf("%d %d", a, b);...