edited by
1,327 views
1 votes
1 votes
int  zap(int n)
{
if (n<=1) then zap =1;
else zap = zap(n-3)+zap(n-1);
}
then the call zap(6) gives the values of zap

Give the proper explanation
edited by

2 Answers

3 votes
3 votes
#include<stdio.h>
int zap(int n)
{
    int p;
    if(n<=1)
    p=1;
    else
    p=zap(n-3)+zap(n-1);
    return p;
}
int main()
{
    int p=zap(6);
    printf("%d",p);
}

 

p will be

p=zap(0) + zap(-1) +zap(1) +zap(-1) +zap(1) +zap(1) +zap(0) +zap(-1) +zap(1)

p=1+1+1+1+1+1+1+1+1=9;

i think this should be solution of this question...

plz tell me if there is wrong any thing in this explanation

Related questions

0 votes
0 votes
2 answers
1
0 votes
0 votes
1 answer
2
Sanjay Sharma asked Mar 1, 2017
309 views