Advertisement
Joao_Joao

Questão 266 Lista de Exercícios IFPB

May 21st, 2022
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int ns[12];
  4.  
  5. int f(int n) {
  6.   if(n == 11) return 0;
  7.   return ns[n] + f(n+1);
  8. }
  9.  
  10. void main() {
  11.   for(int i = 1; i <= 10; scanf("%d", ns+i), ++i);
  12.   int n;
  13.   scanf("%d", &n);
  14.   printf("Soma de todos os elementos do vetor a partir da posicao %d: %d\n", n, f(n));
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement