int toplam, sonuc = 0, top5 = 0, top3 = 0; Console.Write("Bir sayı giriniz: "); int sayi1 = Convert.ToInt32(Console.ReadLine()); Console.Write("bir sayı daha giriniz: "); int sayi2 = Convert.ToInt32(Console.ReadLine()); for (toplam = sayi1; toplam < sayi2; toplam++) if (toplam %5 == 0) { top5 = top5 + toplam; } else if (toplam %3 == 0) { top3 = top3 + toplam; } else { sonuc = sonuc + toplam; } Console.Write("3E bÖLünenLer : {0}\n5e BölüNenLer : {1}\n SayıLarın TopLamı : {2}",top3, top5, sonuc ); Console.ReadLine();
Console.WriteLine("Bir ile yüz arasnda bir sayı tutun"); int küçük = 1, büyük = 100, sayı; string durum; Random rasgele = new Random(); int sayaç = 0; for (int i = 1; i <= 20; i++) { sayı = rasgele.Next(küçük, büyük); sayaç++; if (küçük==büyük) { Console.WriteLine("Sayınız : "+küçük); break; } Console.WriteLine("Sayınız " + sayı + " mı ?"); Console.WriteLine("\nKüçükse K ye Büyükse B ye Bildiysen E ye basın :\n"); durum = Console.ReadLine(); if (durum == "K" || durum == "k") büyük = sayı - 1; if (durum == "B" || durum == "b") küçük = sayı+1; if (durum == "E" || durum == "e") { Console.WriteLine("Ben bu işi biliyorum :) "); break; } if (büyük == 0) { Console.WriteLine("Sayınız : 1 dan küçük olamaz."); break; } } Console.WriteLine("Oyunu oynadığınız için teşekkür ederim " + sayaç + " denemede buldum");
string islem; Console.WriteLine("Toplama İşlemi İçin \"T\"ye basın"); Console.WriteLine("Çıkarma İşlemi İçin \"Ç\"ye basın"); Console.WriteLine("Çarpma İşlemi İçin \"X\"e basın"); Console.WriteLine("Bölme İşlemi İçin \"B\"ye basın"); islem = Console.ReadLine(); if (islem == "T") { Console.WriteLine(Int32.Parse(Console.ReadLine()) + Int32.Parse(Console.ReadLine())); } if (islem == "Ç") { Console.WriteLine(Int32.Parse(Console.ReadLine()) - Int32.Parse(Console.ReadLine())); } if (islem == "X") { Console.WriteLine(Int32.Parse(Console.ReadLine()) * Int32.Parse(Console.ReadLine())); } if (islem == "B") { Console.WriteLine(Int32.Parse(Console.ReadLine()) / Int32.Parse(Console.ReadLine())); }
Form a iki adet textBox Bir adet button ekleyin ve buttonun Click olayına aşağıdaki kodu yazın. int a, b; a = Int32.Parse(textBox1.Text); b=Int32.Parse(textBox2.Text); if(a>b) MessageBox.Show(Convert.ToString(a-b)); else MessageBox.Show(Convert.ToString(b - a));
int a, b; a = Int32.Parse(textBox1.Text); b=Int32.Parse(textBox2.Text); if(a>b) MessageBox.Show(Convert.ToString(a-b)); else MessageBox.Show(Convert.ToString(b - a));
Form a iki adet textBox Bir adet button ekleyin ve buttonun Click olayına aşağıdaki kodu yazın.
MessageBox.Show(Convert.ToString(Int32.Parse(textBox1.Text)-Int32.Parse(textBox2.Text)));
MessageBox.Show(Convert.ToString(Int32.Parse(textBox1.Text)+Int32.Parse(textBox2.Text)));
for (int s = 1; s <= 100; s=s+2) { Console.WriteLine(s.ToString()); }
for (int s = 2; s <= 100; s=s+2) { Console.WriteLine(s.ToString()); }
int t=0; for (int s = 1; s <= 10; s++) { t = t + s; } Console.WriteLine(t.ToString());
for (int s = 1; s <= 10; s++) { Console.WriteLine(s.ToString()); }