Join our Telegram Channel

8000+ STATIC GK MCQs for SSC/ Railway/ PSC
1000 POLITICAL SCIENCE MCQS | EBook
Get 22 nos. GK EBooks | Combo Pack
Current Affairs Monthly Magazine -Subscribe Now!
1000 BIOLOGY MCQS AND ANSWERS | EBook
1000 ECONOMICS MCQS FOR EXAMS | EBook
Mughal Empire MCQs | EBook
ECONOMIC GEOGRAPHY MCQs | EBook
350 MCQs ON INDIAN CONSTITUTION | EBook

Question

What is the following function determining?

	int fn(int a, int b)
	{
		if (b==0) return 0;
		if (b==1) return a;
		return a+fn(a, b-1);
	}
	
A a+b where a and b are integers
B a+b where a and b are non-negative integers
C a*b where a and b are integers
D a*b where a and b are non-negative integers
Answer & Explanation
Option: [B]

The above function is a recursive function. The function will return a+b where a and b are non-negative integers

Advertisement
Advertisement

General Knowledge

Month-wise Current Affairs 2022

Category-wise Current Affairs

Jobs by Qualification

Free Mock Test