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

What are the 5 elements of structure?

553


What are valid operations on pointers?

656


Explain pointer. What are function pointers in C?

616


Difference between constant pointer and pointer to a constant.

601


Why c language?

633






What is extern c used for?

559


Subtract Two Number Without Using Subtraction Operator

343


What are the storage classes in C?

616


What is calloc()?

617


is it possible to create your own header files?

626


Can one function call another?

616


How do you determine the length of a string value that was stored in a variable?

642


about c language

1587


What is array in C

695


What is header file in c?

593