33. Diagrama de Flujo en DFD || Ciclos o Bucles || Suma de números pares desde 1 hasta n

33. Diagrama de Flujo en DFD || Ciclos o Bucles || Suma de números pares desde 1 hasta n

New Section

In this section, the speaker introduces a programming problem related to loops and cycles. The task is to create a program that calculates the sum of all even numbers from one to a given number and determines how many even numbers are present.

Problem Introduction

  • The video presents problem number 11 involving loops and cycles.
  • Users are required to input a number 'n' for the program to calculate the sum of even numbers up to 'n' and determine the count of even numbers.

Variables Initialization and User Input

This part focuses on initializing variables for calculations and obtaining user input for the desired number.

Variable Declaration

  • Initialize variables: 'n' for user input, 'sum' set to zero, and 'count' also initialized as zero.

User Input

  • Prompt the user to enter a number ('n') which will be stored in the variable 'n'.

Loop Implementation

Implementing a loop structure to iterate through numbers up to 'n'.

Loop Structure

  • Utilize a loop structure starting from 1 up to 'n', incrementing by one each time.

Calculating Even Numbers

Determining if a number is even within the loop and performing relevant calculations.

Checking for Even Numbers

  • Use conditional statement within the loop: If 'i mod 2 == 0', increment 'sum' by adding current value of 'i'.

Counting Even Numbers

  • Increment count by one each time an even number is encountered within the loop.

Output Display

Displaying results including sum of even numbers and total count of even numbers found.

Result Presentation

  • Output on screen: Display calculated sum ('sum') of even numbers along with total count ('count') of even numbers found.

Program Testing

Testing program functionality with sample inputs for verification.

Test Cases

  • Enter test cases like 10 or 25, verifying correct output showing sum of even numbers and total count.
Video description

Puedes apuntarte al curso Completo en el siguiente enlace: LINK: https://goo.gl/Lyve5d En este vídeo resolveremos los siguientes problemas: 11. Hacer un programa que imprima la suma de todos los números pares que hay desde 1 hasta n, y diga cuantos números hay. 12. Hacer un programa que imprima la suma de todos los números impares que hay desde n hasta m, y diga cuantos números hay (Propuesto). Descarga los ejercicios 12 y 13 de bucles, en el siguiente link (solo uno): Mega: https://mega.nz/#!oUwWmDLI!A-fZMN2g57JGUYR3XJJiyaLqqFFBHYCLuH8hkSlpofA Mediafire: http://www.mediafire.com/file/uz18a4x1lr56eg5/Ejercicio11y12-Bucles-DFD.rar Visita mi sitio web para más cursos: https://programacionats.zenler.com Sigueme por las redes sociales: Facebook ProgramacionATS: https://goo.gl/sqmEE1 Twiter: https://goo.gl/WE4oaP Hotmail: alejandro.acb@hotmail.com Facebook personal: https://goo.gl/xL9qLl Cuenta paypal para donaciones: migueltaboadas@hotmail.com