Statement of the question: Consider the following functions:
int suc(int n) { return n+1; }
int pred(int n) { return n-1; }
Using these functions (and no arithmetic operator), create recursive functions to determine: (a) The sum of two natural numbers.
#include <stdio.h>
#define pred(n) { return n-1; }
#define suc(n) { return n+1; }
int soma (int x, int y ){
if ( x == 0) return y;
if ( y == 0) return x;
return soma((suc(x)),(pred(y)));
}
int main(void){
int x = 4;
int y = 3;
int result = soma(x,y);
}
Can anyone tell me what the syntax / logic error is in this solution? Thanks in advance