This document contains code to sum the even numbers in an array. The code prompts the user to enter numbers into an array, loops through the array, checks if each number is even using the modulo operator, and adds any even numbers to a running sum variable. Finally, the sum of the even numbers is displayed in a text box.
This document contains code to sum the even numbers in an array. The code prompts the user to enter numbers into an array, loops through the array, checks if each number is even using the modulo operator, and adds any even numbers to a running sum variable. Finally, the sum of the even numbers is displayed in a text box.
This document contains code to sum the even numbers in an array. The code prompts the user to enter numbers into an array, loops through the array, checks if each number is even using the modulo operator, and adds any even numbers to a running sum variable. Finally, the sum of the even numbers is displayed in a text box.
Public Class Form1 Dim n As Integer Dim v(100) As Integer Dim i As Integer Dim s As Integer Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click n = TextBox1.Text For i = 1 To n v(i) = InputBox("Introduceti valoarea " + Str(i)) Next s = 0
For i = 1 To n If v(i) Mod 2 = 0 Then s = s + v(i) End If Next End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
RichTextBox1.AppendText("suma valorilor pare este " + Str(s)) End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load