Home / MCQ Bank / Computer
Computer Miscellaneous On Data Structures

What is the output of the following code? #include<stdio.h> int cnt =0; int my_function(int n, int sm) { int i, tmp_sm; for(i=1;i<=n;i++) { tmp_sm = recursive_sum_of_digits(i); if(tmp_sm == sm) cnt++; } return cnt; } int recursive_sum_of_digits(int n) { if(n == 0) return 0; return n % 10 + recursive_sum_of_digits(n/10); } int main() { int n = 20, sum = 3; int ans = my_function(n,sum); printf("%d",ans); return 0; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option C • 2

Related Computer Questions

Which class in Java is responsible for deserialization during Java Serialization? What is the average time complexity of a successful search using binary search? What does the next statement do in R? The running time of implementing naive solution to min-cut problem is? Which is the best view for getting your thoughts for a presentation out on the computer?