1. Anasayfa
  2. Nesne Tabanlı Programlama

C# Örnekleri – For Döngüsü 1-100 Arasındaki Sayılar

C# Örnekleri – For Döngüsü 1-100 Arasındaki Sayılar
0

C# örneklerimize 1-100 arasındaki sayılarla for döngüsü ile yapacağımız uygulama ile devam ediyoruz uygulamada 1-100 arasındaki sayıların toplamı, 1-100 arasındaki çift sayıların toplamı, 1-100 arasındaki tek sayıların toplamı, 1-100 arasındaki 3-5’e tam bölünen sayıların toplamı ve 1-100 arasındaki sayıların ortalamasını hesaplayacağız. İlk olarak aşağıdaki form tasarımını oluşturuyoruz.
fordongussu100

 private void button1_Click(object sender, EventArgs e)
        {
            int toplam=0;
            for (int i = 0; i <= 100; i++)
            {
                toplam += i;
            }
            textBox1.Text = toplam.ToString();
        }
        //http://www.bilisimogretmeni.com/
        private void button2_Click(object sender, EventArgs e)
        {
            int toplam = 0;
            for (int i = 0; i <= 100; i += 2)
            {
                toplam += i;
            }
            textBox2.Text = toplam.ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int toplam = 0;
            for (int i = 1; i <= 100; i += 2)
            {
                toplam += i;
            }
            textBox3.Text = toplam.ToString();
        }
        //http://www.bilisimogretmeni.com/
        private void button4_Click(object sender, EventArgs e)
        {
            int toplam = 0;
            for (int i = 0; i <= 100; i++)
            {
                if (i % 3 == 0 && i % 5 == 0)
                {
                    toplam += i;
                }
            }
            textBox4.Text = toplam.ToString();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            double toplam = 0;
            for (int i = 0; i <= 100; i++)
            {
                toplam += i;
            }
            toplam /= 100;
            textBox5.Text = toplam.ToString();
        }
Bu İçeriğe Tepkin Ne Oldu?
  • 4
    ba_ar_l_
    Başarılı
  • 2
    gayet_yi
    Gayet İyi
  • 6
    te_ekk_rler
    Teşekkürler
  • 1
    anlamad_m
    Anlamadım
  • 0
    yetersiz
    Yetersiz
Subscribe
Bildir
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Yorum
Inline Feedbacks
View all comments