Ques 1 Function
Consider the following function f is
int f(int n)
{
if(n<=0)
return 1;
else if(n%2==0) return f(n/2);
else return f(3n-1);
}
Assume that arbitrary large integers can be passed as a parameter to the following to the function,consider the following statements.
i) The function f terminates for finitly many different values of n>=1.
ii) The Function f terminates for infintely many different values of n>=1.
iii) The function f terminates for finitly many different values of n>=1.
iv) The function f does not terminate for infinitly many different values of n>=1.
Which of the following options is true of the above?
Ques 2 Function
The keyword is used to transfer control from a function back to the calling function is
Ques 3 Function
Consider the following C-program
double foo(double);/*Line 1*/
int main( ){
double da,db;
//input da
db=foo(da)
}
double foo(double a){
return a;
}
The above code complied without any error or warning.if line is deleted then the above code will be see
Ques 4 Function
Consider the following C-program
void foo(int n,int sum){
int k=0,j=0;
if(n==0) return 0;
k=n%10;
j=n/10;
sum=sum+k;
foo(j,sum);
printf("%d",k);
}
int main( ){
int a=2048,sum=0;
foo(a,sum);
printf("%d\t",sum);
}