Diseñar un algoritmo que permita calcular los 4 primeros números pares, para posteriormente calcular su media aritmética.
Codigo Fuente en Visual Basic
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cad As String = "" Dim sum As Double = 0.0 Dim media As Double = 0.0 For r As Integer = 1 To 4 sum = sum + (2 * r) cad = cad + " " + Trim(2 * r) Next r TextBox1.Text = cad media = sum / 4 TextBox2.Text = Trim(media) End Sub End Class
No hay comentarios:
Publicar un comentario