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

Answers were Sorted based on User's Feedback



C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+z..

Answer / 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

C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+z..

Answer / guest

b

Is This Answer Correct ?    15 Yes 4 No

C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+z..

Answer / deepa

error there is no keyword as then ,therefore it will
treat 'then' as a variable which wud lead it to compilation
error

Is This Answer Correct ?    15 Yes 8 No

C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+z..

Answer / manishsoni

int zap(int n)
{
int a;
if(n<=1)
a=1;
else
a=zap(n-3)+zap(n-1);
return a;
}
main()
{
int result;
result=zap(6);
printf("%d",result);
getch();
}
it gives us 9;
Manish soni(MoNu)

Is This Answer Correct ?    5 Yes 1 No

C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+z..

Answer / guest

9

Is This Answer Correct ?    1 Yes 0 No

C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+z..

Answer / madhu

if (n<=1)
zap = 1;
it gives a compile time error invlaid l value assignment.
zap is a function and cannot be assigned a value

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More C Interview Questions

In how much time you will write this c program? Prime nos from 1 to 1000

2 Answers   TCS,


what is c programming?

3 Answers   TCS,


Why is c faster?

0 Answers  


Two's compliment of -5

4 Answers   Adobe,


Explain function pointer with exapmles.

2 Answers  






What is a substring in c?

0 Answers  


what will be the output for the following main() { printf("hi" "hello"); }

5 Answers   RoboSoft,


What is pointers in c with example?

0 Answers  


Does free set pointer to null?

0 Answers  


Write a C program to convert an integer into a binary string?

1 Answers  


write a program to add two numbers of any size.....(remember any size)

1 Answers  


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

0 Answers   TCS,


Categories