how to print numbers in c code example
Example 1: how to print int in c
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
scanf("%d", &number);
printf("You entered: %d", number);
return 0;
}
Example 2: print digits of a number in c
#include <stdio.h>
int printDigits(int n){
int digit;
if(n < 10){//caso base
digit = n;
printf("%d\n", digit);
}else{
digit = printDigits(n/10);
digit = printDigits(n%10);
}
return digit;
}
int main(){
int num = 3467678;
printDigits(num);
return 0;
}