GATE Exam  >  GATE Questions  >  Consider the following recursive c function: ... Start Learning for Free
Consider the following recursive c function: PROGRAMMING
void ABC (int i)
{
if(i<1)
return;
ABC(i-2);
ABC(i-4);
printf(“%d”, i);
}.
If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?
  • a)
    5
  • b)
    7
  • c)
    9
  • d)
    12
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
Consider the following recursive c function: PROGRAMMINGvoid ABC (int ...
ABC(0) = 1
ABC(-1) = 1(itself).
ABC(1) = ABC(-1)+ABC(-3)+1 = 3
In general ,
ABC(i) = ABC(i-2) + ABC(i-4) + 1.
ABC(6) = ABC(4) + ABC(2) + 1
ABC(2) = ABC(0) + ABC(-2) + 1
= 1 + 1 + 1 = 3
ABC(4) = ABC(2) + AB(0) + 1
= 3 + 1 + 1 =5
ABC(6) = 5 + 3 + 1
= 9.
View all questions of this test
Explore Courses for GATE exam

Similar GATE Doubts

Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer?
Question Description
Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer?.
Solutions for Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer?, a detailed solution for Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the following recursive c function: PROGRAMMINGvoid ABC (int i){if(i<1)return;ABC(i-2);ABC(i-4);printf(“%d”, i);}.If the ABC (6) function is being called in main () then how many times will the ABC() function be invoked before returning to the main()?a)5b)7c)9d)12Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev