Advertisement
Joao_Joao

Questão 261 Lista de Exercícios IFPB

May 21st, 2022
1,444
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data Copied
Advertisement