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

Which is better oop or procedural?

0 Answers  


2) Write a program that will help Air Traffic Control for an airport to view the sequence of flights ready for take-off. The airport can accommodate 10 flights waiting for take-off at any point in time. Each flight has a unique 3 digit numeric identifier. &#61550; Each time a flight takes-off, Air Traffic Control adds a flight to the waitlist. Each time a flight is added to the waitlist, the list of flights waiting to take-off must be displayed. &#61550; When a flight is cleared for take-off, Air Traffic Control removes the flight from the waitlist. Each time a flight takes-off, the list of flights waiting to take-off must be displayed. &#61550; Sequence of take-off is the sequence of addition to the waitlist

0 Answers  


What do mean by network ?

0 Answers  


What is indirection in c?

0 Answers  


Write a program to print the prime numbers from 1 to 100?

7 Answers  






1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(ā€œ%dā€,x); --x; } }

7 Answers   CSC,


What does typeof return in c?

0 Answers  


how to swap two nubers by using a function with pointers?

1 Answers  


3. Program to print all possible substrings. ex: String S St Str Stri Strin String t tr tri trin tring r

3 Answers   Huawei,


Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent

0 Answers  


How many ways are there to swap two numbers without using temporary variable? Give the each logic.

9 Answers  


why program counter is 16 bit?

3 Answers  


Categories