C program code

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
[a] 8 [b] 9 [c] 6 [d] 12 [e] 15

Answer Posted / gg

Error::invalid lvalue in assignment
for both the statements followed by IF & ELSE .

coz zap is a function name.And trying to assign a value.

if the Code is :
int zap(int n)
{
int zap1;
if(n<=1)
(zap1 = 1);
else
(zap1 = zap(n-3)+zap(n-1));
}
Ans Is :: 1


If the Code is :
int zap(int n)
{
int zap1;
if(n<=1)
return (zap1 = 1);
else
return (zap1 = zap(n-3)+zap(n-1));
}
Ans Is ::9

Is This Answer Correct ?    22 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how logic is used

1500


What is #include stdlib h?

616


What are c identifiers?

629


Is a house a mass structure?

641


What is a ternary operator in c?

652






How can I remove the trailing spaces from a string?

616


how to write optimum code to divide a 50 digit number with a 25 digit number??

2755


What should malloc() do?

645


What is the auto keyword good for?

625


What does sizeof return c?

603


What standard functions are available to manipulate strings?

560


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

656


What is typedf?

670


Explain why can’t constant values be used to define an array’s initial size?

854


How can I read and write comma-delimited text?

621