🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Burak HABER / C# / Console yazma if ve for dongusunun kullanimi vs.. (ders23)

1-) C# - Console yazma if ve for dongusunun kullanimi vs.. (ders23)

 

using System;

using System.Windows.Forms;

 

namespace WindowsFormsApp7

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

 

        private void button1_Click(object sender, EventArgs e)

        {

            //Console.WriteLine("naber knk"); // Console demek  view->output demek.. write = yazmak .... line = satır

 

            // String consoldakideger = Console.ReadLine(); // ReadLine -> satırı oku demek

            // MessageBox.Show(consoldakideger);

 

            /*

             Soru 1:

             Kullanıcının adı ve bir sayı klavyeden girilerek, girilen sayı kadar ekrana kullanıcının adını

             yazan konsol programını yapınız.

             */

            /*int sayim = Convert.ToInt32(textBox2.Text);

            for (int i = 0; i <= sayim; i++)

            {

                string ekranayaz = textBox1.Text + "-" + i;

                Console.WriteLine(ekranayaz);

            } // soru 1 bitti*/

 

            /*

             Soru 2:

             2+5+8+11+14+17+20+23+26+29+32+35…….+50 şeklindeki matematiksel serinin toplamını bulup,

             ekrana yazan konsol programını yapınız.

             */

            /*

            int toplam = 0;

            for (int i = 2; i <= 50; i = i + 3)

            {

                int sonuc = toplam;

                toplam = toplam + i;

                string sonuc1 = sonuc+" + " + i+"= "+toplam;

                Console.WriteLine(sonuc1);

            }// soru 2 bitti*/

 

            /*

             Soru 3:

             Klavyeden 10 adet sayı girilerek, bu sayılardan çift olanların toplamını bulup, ekrana yazan

             konsol programını yapınız.

             */

 

            /*i++;

            if (i>10 )

            {

                MessageBox.Show("10 dan fazla giremezsin ! ");

            }

            else

            {

                listBox1.Items.Add(i + "-" + textBox2.Text);

            }

            }

        int i = 0;*/

 

 

 

            /*

             Soru 4:

             1 + 2 + 3 + 4 + 5 + ……………. 10 şeklindeki matematiksel serinin toplamını bulup ekrana yazan konsol

            uygulamasını yapınız.

             */

            /*

            int toplam = 0;

            for (int i = 1; i <= 10; i++)

            {

                toplam = toplam + i;

               

            }

            Console.WriteLine(toplam);*/

 

            /*

            Soru 5: yıldız sorusu

             */

            /* string yildiz = "*"; // yildiz; değişkendir. string,int,double; veritipidir. for; döngüdür.

 

             for (int i = 1; i <= 6; i++)

             {

                 Console.WriteLine(yildiz);

                 yildiz = yildiz + "*";

             }*/

 

 

            /*

             Soru 6: Klavyeden girilen 5 adet sayıdan kaç tanesinin negatif olduğunu bulan konsol programını  yapınız.

             */

            /*

            i++;

            if (i==6)

            {

                //MessageBox.Show("5 den fazla giremezsiniz ");

                for (int i = 0; i < listBox1.Items.Count; i++)

                {

                    int sayim = Convert.ToInt32(listBox1.Items[i].ToString());

                    if (sayim<0)

                    {

                        Console.WriteLine("negatif = "+sayim);

                    }

                }

                i = 5;

            }

            else

            {

                listBox1.Items.Add(textBox2.Text);

            }

 

 

        }

 

        int i = 0;*/

            /* Soru 7: Tex box girilen sayı kadar yıldız koyan kodlama.

            

 

 

            string yildiz = "*";

 

            for (int i = 1; i <= Convert.ToInt32(textBox2.Text); i++)

            {

                Console.WriteLine(yildiz);

                yildiz = yildiz + "*";

            }*/

 

 

            /*

             Soru8 : textboxa girilen pozitif sayıya kadar olan çift sayıların toplamını bulan programı yazınız.

             */

 

            /*int toplam = 0;

            for (int i = 2; i <= Convert.ToInt32(textBox2.Text); i=i+2)

            {

                toplam = toplam + i;

            }

            Console.WriteLine(toplam);*/

 

            // ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

            /*

             Soru9 : textboxa girilen pozitif sayıya kadar olan tek sayıların toplamını bulan programı yazınız.
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 Ödev

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

 

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            int toplam = 0;

            for (int i = 0; i <= Convert.ToInt32(textBox1.Text); i = i + 2)

            {

                if (i == 0)

                {

                    i++;

                }

                toplam = toplam + i;

            }

            Console.WriteLine(toplam);

        }

    }

}

 

             Soru10 : textboxa girilen sayı kadar * in tersini yap ve consola yaz

             Soru11 : ilk buttona tıkladıgında 1-1000 arasında rasgele 30 tane sayı üret. bu 30 sayıyı listboxa ekle. sonra başka buttona tıkladıgında bu 30 sayıların içinde çift olanları console yazan uygulamayı yaz

             Soru12 : 1-1000 arasında rastgele 20 tane sayı üret. bu sayıların çift olanlarını topla ve consola yaz

 

             */

 

 

 

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

        }

    }

}

 

 2021 Mart 11 Perşembe
 371