17 - Dizi Örneği 2

 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 WindowsFormsApplication2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        int[] notlar = { 45, 10, 35, 99, 20 };

        int enBuyuk;

        private void button1_Click(object sender, EventArgs e)

        {

            enBuyuk = notlar[0];

            for (int i = 0; i < notlar.Length; i++)

            {

                if (notlar[i]>enBuyuk)

                {

                    enBuyuk = notlar[i];

                }

            }

            MessageBox.Show(enBuyuk.ToString());

        }

        float toplam = 0;

        float ortalama;

        private void button2_Click(object sender, EventArgs e)

        {

            for (int i = 0; i < notlar.Length; i++)

            {

                toplam = toplam + notlar[i];

            }

            MessageBox.Show(toplam.ToString());

            ortalama = toplam / notlar.Length;

            MessageBox.Show(ortalama.ToString());


        }

    }

}


Yorumlar

Bu blogdaki popüler yayınlar

14 - Dizi Oluşturma, Değer Atama

12 - Bir Boyutlu Diziler - Çalışma Soruları

27 - Koleksiyonlar: ArrayList()