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

/*what is the output for the code*/ void main() { int r; r=printf("naveen"); r=printf(); printf("%d",r); getch(); }

1 Answers   CDAC,


What is the use of linkage in c language?

0 Answers  


What is the scope of static variable in c?

0 Answers  


design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.

0 Answers   TCS,


Write a c program to read a positive number and display it in words.? ex: 123=one two three help me....

2 Answers  






Give a fast way to multiply a number by 7

15 Answers   Accenture, Aricent, Microsoft,


what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these

2 Answers   IBM,


What is data structure in c language?

0 Answers  


What is the difference between union and anonymous union?

0 Answers   Hexaware,


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

0 Answers   TISL,


Program to find the value of e raised to power x using while loop

5 Answers   IBM, N Tech,


What's the total generic pointer type?

0 Answers  


Categories