A small correction, you want it to return from N to 0 and not from 0 to N, since you are decrementing recursively, if you really want it to go from 0 to N I change the code.
Another thing you forgot is that you are not printing the numbers, you are only giving return, ie it performs the entire calculation but does not print.
Another observation is that if you want to start from 0 then you have to change 1 by zero in your first if:
#include<stdio.h>
int imprimenumeros(int n){
printf("%d\n", n );
if (n==0){
return 0;
}
else {
return imprimenumeros(n-1);
}
}
void main (){
int n;
int y;
printf("digite um numero\n");
scanf("%d", &n);
imprimenumeros (n);
}
Now if you really want to incremental from 0 to a given N, simply pass your initial variable "in this case is 0" along with your terminal variable "which in this case is N" and increase recursively: / p>
#include<stdio.h>
int imprimenumeros(int n, int y){
printf("%d\n", y);
if (n>y){
return imprimenumeros(n, y+1);
}
else {
return 0 ;
}
}
void main (){
int n;
int y = 0;
printf("digite um numero\n");
scanf("%d", &n);
imprimenumeros (n, y);
return 0;
}