İstenilen Sayı Girilene Kadar Girilen Sayıların Ortalamasını Bulma — Csharp
[code lang=”csharp”]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication36
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}//www.gorselprogramlama.com
int toplam, ortalama, i;
private void Form1_Load(object sender, EventArgs e)
{
toplam = 0;
ortalama = 0;
i = 0;
}
private void button1_Click(object sender, EventArgs e)
{
int sayi = Convert.ToInt32(textBox1.Text);
if (sayi == 0)
{//www.gorselprogramlama.com
MessageBox.Show("İşlem Bitmiştir. ");
toplam = 0;
i = 0;
ortalama = 0;
}
else
{
toplam = toplam + sayi;
i++;
}
try
{
ortalama = toplam / i;
label2.Text = i + ". kez sayi girdiniz. Ortalama: " + ortalama.ToString();
}
catch
{
}//www.gorselprogramlama.com
}
}
}
[/code]

