Is there any way to programatically find if the given code is taking recursive
approach or iterative apporaoch using concept of files in C programming.
#include <stdio.h>
int sum(int n);
int main(){
int num,add;
printf("Enter a positive integer:\n");
scanf("%d",&num);
add=sum(num);
printf("sum=%d",add);
}
int sum(int n){
if(n==0)
return n;
elsereturn n+sum(n-1); /*self call to function sum() */
}
I know this code is using recursive approach..
But are there programs or tools that could find if the program submitted in .txt file is using recursive approach or iterative approach.
I thought you wanted to write tool to detect recursion, I guess that is not the case.
are there programs or tools that could find if the program ... is using recursive approach or iterative approach.
Probably, I don't think that on it's own is particularly useful. There may be some tool that does this as part of some larger analysis. But I don't know of any.