in Programming in C retagged by
10,881 views
23 votes
23 votes

Consider the following $\text{C}$ program:

#include<stdio.h>

int counter=0;

int calc (int a, int b) {
        int c;
        counter++;
        if(b==3) return (a*a*a);
        else {
                c = calc(a, b/3);
                return (c*c*c);
        }
}

int main() {
        calc(4, 81);
        printf("%d", counter);
}

The output of this program is ______.

in Programming in C retagged by
by
10.9k views

3 Comments

Anyone know how to see the output of what the calc() function is returning??

I know it will be very huge number but even if I change to long long int then also not able to see output. just wanted to know is there is any facality in C to see that much huge no. below is my code feel free to edit and let me know if you are able to see output. cause it is outputing 0 and i think this will going off the double doube int max limit.

https://ideone.com/H3FCkD
 

0
0
Just count the number of digits in the result. And a double value can hold how many digits?
1
1
thanks this works...🙂
0
0

5 Answers

0 votes
0 votes

 

4 function calls.
counter = 4
Answer:

Related questions