Home
About Us
Contact Us
Bookmark
Saved Bookmarks
Current Affairs
General Knowledge
Chemical Engineering
UPSEE
BSNL
ISRO
BITSAT
Amazon
ORACLE
Verbal Ability
→
Algorithms
→
Analysis Of Algorithms (Recurrences) in Algorithms
→
What does the following function do?int fun(int x,...
1.
What does the following function do?int fun(int x, int y){if (y == 0) return 0;return (x + fun(x, y-1));}(A) x + y(B) x + x*y(C) x*y(D) xy
Answer»
Show Answer
Discussion
No Comment Found
Post Comment
Related InterviewSolutions
What does the following function do?int fun(int x, int y){if (y == 0) return 0;return (x + fun(x, y-1));}(A) x + y(B) x + x*y(C) x*y(D) xy
What does the following function do?int fun(unsigned int n){if (n == 0 || n == 1)return n;if (n%3 != 0)return 0;return fun(n/3);}(A) It returns 1 when n is a multiple of 3, otherwise returns 0(B) It returns 1 when n is a power of 3, otherwise returns 0(C) It returns 0 when n is a multiple of 3, otherwise returns 1(D) It returns 0 when n is a power of 3, otherwise returns 1
Output of following program?#include<stdio.h>void print(int n){if (n > 4000)return;printf("%d ", n);print(2*n);printf("%d ", n);}int main(){print(1000);getchar();return 0;}(A) 1000 2000 4000(B) 1000 2000 4000 4000 2000 1000(C) 1000 2000 4000 2000 1000(D) 1000 2000 2000 1000
What does fun2() do in general?int fun(int x, int y){if (y == 0) return 0;return (x + fun(x, y-1));}int fun2(int a, int b){if (b == 0) return 1;return fun(a, fun2(a, b-1));}(A) x*y(B) x+x*y(C) xy(D) yx
Predict output of following program#include <stdio.h>int fun(int n){if (n == 4)return n;else return 2*fun(n+1);}int main(){printf("%d ", fun(2));return 0;}(A) 4(B) 8(C) 16(D) Runtime Error
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply
Your experience on this site will be improved by allowing cookies. Read
Cookie Policy
Reject
Allow cookies