我写了2个函数,一个输入正整数,另一个显示输入的整数。如何将变量的值传递给函数,该函数应打印输入?
我的代码:
#include <stdio.h>
int enter_number(){
printf("Please enter a positive Number\n");
int number = 0;
scanf("%i", &number);
if (number <= 0){
enter_number();
}
else {
return number;
}
}
## Heading ##void show_number(){
printf("the number is: %i", number);
}
int main(){
enter_number();
show_number();
return 0;
}