Computer Science, asked by vinothapalraj, 3 months ago

15. What will be the output of the following program?
Ninclude<stdio.h>
#include<string.hr
void calculate(char *a, int i, int n):
void swap (chur x, chary:
int m= 0;
int main()
IN
char st[10] = "loT":
int len-0.140:
len = strlen(str):
calculate(str. o. len-I):
printf("%din".m):
void swap (char *x, char "y) |
chur lemp:
lemn
exy
Ny - temp:
!
void calculatctchar n. mnt 1. ini n)
mt=0;​

Answers

Answered by nanananana70
0

Answer:

As I (variable) is declared as static it only gets initialized once .

main(5) calls main(4) calls main(3) calls main(2) calls main(1) ,In main(1) ,if condition fails so recursion stops and nothing gets printed in that call . Now function backtracks to previous calls and prints I value , which is zero 4 times (as static variables have same value across all function calls and I became zero in main(1))

Note : main(x) ,Here x denotes the value of I when that particular main function started execution

Similar questions