Advertisement
Joao_Joao

Questão 261 Lista de Exercícios IFPB

May 21st, 2022
1,901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.16 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int f(int n) {
  4.   if(!n) return 0;
  5.   return n % 10 + f(n / 10);
  6. }
  7.  
  8. void main() {
  9.   int n;
  10.   scanf("%d", &n);
  11.   printf("%d\n", f(n));
  12. }
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement