Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Sum Vector Elements | R Loops Tutorial
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Control Flow in R

bookChallenge: Sum Vector Elements

Tarefa

Swipe to start coding

Write a function that takes a numeric vector and returns the sum of its elements using a for loop.

  • Initialize a variable to store the sum as zero.
  • Use a for loop to iterate over each element in the input vector.
  • Add each element to the sum variable.
  • Return the sum variable as the result.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Sum Vector Elements

Deslize para mostrar o menu

Tarefa

Swipe to start coding

Write a function that takes a numeric vector and returns the sum of its elements using a for loop.

  • Initialize a variable to store the sum as zero.
  • Use a for loop to iterate over each element in the input vector.
  • Add each element to the sum variable.
  • Return the sum variable as the result.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

some-alt