C# Kodları

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

//X adet_sayinin_ortalamasini_bulan_program using System; using System.Collections.Generic; using System.Linq; using System.

Text; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { int toplam = 0; //Girilen saylarn toplamn bu deikene atayacaz. Console.Write("Ka adet say girileceini yaznz..\n"); //Kulancdan ka adet saynn ortalamasn almak istediimizi soruyoruz. string str = Console.ReadLine(); int adet = Int32.Parse(str); //Alnan cevab adet deikenine atayarak dngmzn saysn belirliyoruz. for (int i = 1; i <= adet; i++) { Console.Write(i + ". sayy girin:"); //1. sayy girin veya 2. sayy girin gibi ekrana say numarasn yazdryor int sayi = Int32.Parse(Console.ReadLine()); toplam = toplam + sayi; //lk satrda toplam deikenini sfr(0)'a eitlemitik. imdi kullanc say girdike toplamn deerini artryoruz. } double ortalama = (double)toplam / adet; //Ortalamy hesaplyoruz ve yazdryoruz. Console.Write("Girdiiniz saylarn ortalamas= " + ortalama); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("leminiz tamamdr imdi kmak iin bir tua basn...:)"); Console.ReadKey(); } } }

//Bu program 5'e blnen 7'ye blnmeyen saylarn toplamn ve ka adet olduunu ekrana yazdryor.. int adet = 0; int toplam = 0; for (int i = 1; i <= 1000; i++) { if ((i % 5 == 0) && (i % 7 != 0)) { Console.WriteLine(i); toplam += i; adet++; } } Console.WriteLine("\n\n{0} say bulundu..", adet); Console.WriteLine("Toplamlar : {0}", toplam); Console.WriteLine("kmak iin bir tua basn.."); Console.ReadKey();

int enbuyuk = 0;

int enkucuk = 100; //Klavyeden girilen 10 adet notun en byk ve en kn bulan program... Console.WriteLine("10 adet notun en byk ve en kn bulan program..."); for (int i = 1; i <= 10; i++) { Console.WriteLine(i + ". sayy giriniz:"); int sayi = Int32.Parse(Console.ReadLine()); if (sayi > 100) { Console.WriteLine("Girdiiniz say 100'den byk olamaz!"); i--; } else { if (enbuyuk < sayi) enbuyuk = sayi; if (enkucuk > sayi) enkucuk = sayi; } } Console.WriteLine("En byk say =" + enbuyuk); Console.WriteLine("En kk say =" + enkucuk); Console.ReadKey();

//Girilen 10 notun en byk ve en kn bulup ortalamasn hesaplayan program.. int max = 0, min = 100, toplam = 0; int adet = 10; int not; for (int i = 0; i < adet; ) { Console.WriteLine("Notunuzu giriniz :"); not = Convert.ToInt32(Console.ReadLine()); if (not < 0 || not > 100) Console.WriteLine("Yanl not girdiniz.."); else { if (not > max) max = not; else if (not < min) min = not; toplam += not; i++; } } Console.WriteLine("\nEn dk not : {0}", min); Console.WriteLine("\nEn byk not : {0}", max); float Ortalama=(float)toplam/(float)adet; Console.WriteLine("\nOrtalama {0}", Ortalama); Console.ReadKey();

Git: Console.Write("Asal Olup Olmadigini grenmek Istediginiz Sayiyi Giriniz:"); string a = Console.ReadLine();

int d = Convert.ToInt32(a); int b; int c = 0; if (d > 10000) goto Git; { for (b = 2; b < d; b++) { if (d % b == 0) c++; } if (c == 0) { Console.WriteLine("Bu Asal Saydr:" + a); } else if (c > 0) { Console.WriteLine("Bu Asal Say Degildir:" + a); } Console.ReadLine();

// 0 ie 100 arasnda girilen notun en byk ve en kk elamann ekrana yazdryorum.. int Max = 0, Min = 100, Toplam = 0; int Adet = 10; int not; for (int i = 1; i <= 10; i++) { { Console.Write("{0}. Notu Giriniz : \n", i); not = Convert.ToInt32(Console.ReadLine()); if (not < 0 || not > 100) Console.WriteLine("Yanl not girdiniz..."); else { if (not > Max) Max = not; else if (not < Min) Min = not; Toplam += not; } } } Console.WriteLine("\n En Yksek Not : {0}", Max); Console.WriteLine("\n En Dk Not : {0}", Min); float Ortalama = (float)Toplam / (float)Adet; Console.WriteLine("\n Ortalama : {0}", Ortalama); Console.WriteLine("kmak iin herhangi bir tua basnz.."); Console.ReadKey();

byte sayi;

Console.WriteLine("Say Giriniz.. (0-255) aras olmal"); sayi = Convert.ToByte(Console.ReadLine()); for (byte j = 8; j >= 1; j--) { byte And = 1; for (int k = 1; k <= j - 1; k++) { And *= 2; } byte bit = (byte)((sayi & And) >> j - 1); Console.Write(bit); } Console.ReadKey();

// stenilen Adette Yldzlarla(*) satr stun oluturuluyor.. int satir, sutun; Console.Write("Satr Says :"); satir = Convert.ToInt32(Console.ReadLine()); Console.Write("Stun Says :"); sutun = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); for (int i = 0; i < sutun; i++) { for (int j = 0; j < satir; j++) { Console.Write("*"); } Console.WriteLine(); } Console.ReadLine();

int aralik = 0; for (int i = 1; i <= 30; i++) { Console.WriteLine(i + ". rencinin yan giriniz.."); int yas = Int32.Parse(Console.ReadLine()); if ((yas >= 13) || (yas <= 15)) aralik++; } Console.WriteLine("Ya 13 ile 15 arasnda olanlarn says = " + aralik); Console.ReadKey();

//Bu programda istediimiz boyutta dizi grnm elde edebiliyoruz.. int adet = 0; for (int i = 0; i <= 200; i += 5) { if (adet % 6 == 0) { Console.WriteLine(); } Console.Write("{0,3} ", i); adet++;

} Console.WriteLine("\n"); Console.ReadKey();

string[] dizi = new string[5]; string str; int indeks; dizi.SetValue("Sefer", 0); dizi.SetValue("Feride", 1); dizi.SetValue("Gken", 2); dizi.SetValue("hsan", 3); dizi.SetValue("Yusuf", 4); Console.WriteLine("Aranacak yaz : "); str = Console.ReadLine(); Array.Sort(dizi); indeks = Array.BinarySearch(dizi,str); if (indeks <= -1) Console.WriteLine("Yaz bulunamad..."); else Console.WriteLine("{0}. indekste bulundu", indeks); Console.WriteLine("by recep"); Console.ReadKey();

//Deerleri ieriden girilen dizinin en byk deerini bulan program. int[] dizi = new int[5]; dizi[0] = 1; dizi[1] = 2; dizi[2] = 3; dizi[3] = 4; dizi[4] = 5; int i; int max = dizi[0]; for (i = 0; i < 5; i++) { if (dizi[i] > max) { max = dizi[i]; } } Console.WriteLine("Dizinin en byk deeri = " + max); Console.ReadKey();

//ki sayy birbiriyle arpmnn sonucuna kendi iinde toplama yoluyla eriim.. int sayi1, sayi2; int sayac = 0; Console.Write("1. sayy girin :\n"); sayi1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("2. sayy girin :"); sayi2 = Convert.ToInt32(Console.ReadLine()); while (sayi2 > 0) { sayac += sayi1; sayi2 -= 1; } Console.Write("Sonu = " + sayac); Console.ReadLine();

//Klavyeden girilen ve istenilen adette saylarn ortalamasn hesaplayan program. int toplam = 0; Console.WriteLine("Ka adet say girileceini yazn : \n"); string str = Console.ReadLine(); int adet = Int32.Parse(str); for (int i = 1; i <= adet; i++) { Console.WriteLine(i + ". sayy girin "); int sayi = Int32.Parse(Console.ReadLine()); toplam = toplam + sayi; } double ortalama = (double)toplam / (double)adet; Console.WriteLine("\nGirdiiniz saylarn ortalamas = " + ortalama); Console.WriteLine("\nkmak iin herhangi bir tua basnz.."); Console.ReadKey();

//Klavyeden girilen istenilen adette saynn tek tek karelerini alan program.. Console.WriteLine("Ka adet saynn karesi alnsn?.."); int adet = Convert.ToInt32(Console.ReadLine()); for (int i=1; i <=adet; i++) { Console.WriteLine(i + ". sayy girin :"); int sayi = Int32.Parse(Console.ReadLine()); sayi = sayi * sayi; Console.WriteLine(i + ". saynn karesi = " + sayi); } Console.WriteLine("kmak iin herhangi bir tua basnz.."); Console.ReadKey();

// Tam doru deil ama alyor girilen dizide ka adet 7 olduunu buluyor.. int toplam = 0; int carpim = 1; int sayi, i; int bol = 0; for (i = 1; i <= 25; i++) { Console.Write(i + ". sayy girin = "); sayi = Convert.ToInt32(Console.ReadLine()); if (sayi<0) { toplam += sayi; } else if ((sayi%2)==0) { carpim *= sayi; } else { bol++; } } Console.Write("Toplam = " + toplam + "arpm = " + carpim + "Yedilerin adedi = " + i); Console.ReadKey();

// Girilen karakterlerin harf olarak deilde cmle olarak ka adet girilmi tabi en son "." //konulduktan sonra ekrana yazdran program.. string karakter; Console.WriteLine("Karakteri giriniz:"); karakter = Convert.ToString(Console.ReadLine()); int ksayi = 0; while (karakter != ".") { Console.WriteLine("Karakteri giriniz.."); karakter = Convert.ToString(Console.ReadLine()); ksayi = ksayi + 1; } Console.WriteLine("Toplam karakter says = " + "{0}", ksayi); Console.ReadKey();

Console.WriteLine("Klavyeden bulan program..");

girilen N says kadar nottan en byk ve en kk olann

Console.Write("\nNot saysn girin :"); int adet = Int32.Parse(Console.ReadLine()); int enbuyuk = 0, enkucuk = 100; int toplam = 0; for (int i = 0; i < adet; i++) { Console.Write(i + 1 + ". notu giriniz :"); int not = Convert.ToInt32(Console.ReadLine()); toplam = toplam + not; if (not > 100 || not < 0) { Console.Write("Yanl not girdiniz. Ltfen geerli not giriniz..\n"); i--; continue; } if (not > enbuyuk) enbuyuk = not; if (not < enkucuk) enkucuk = not; } double ortalama = (double)toplam / (double)adet; Console.WriteLine("\nEn byk not : " + enbuyuk); Console.WriteLine("\nEn kk not : " + enkucuk); Console.WriteLine("\nNot ortalamas : " + ortalama); Console.WriteLine("\nkmak iin herhangi bir tua basnz..."); Console.ReadKey();

//Onluk arpm tablosu: (16.06.2011 aramba) Console.WriteLine("<< Onluk arpm Tablosu >>\n"); for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { int carpim = i * j; Console.WriteLine(" {0} " + "* " + "{1} " + "= " + "{2}", i, j, carpim); } Console.WriteLine("\n -------------\n"); }

Console.ReadKey();

//Girilen Deere Kadar Olan Saylarn Toplam int toplam = 0; int a; Console.WriteLine("Say girin : "); a = Convert.ToInt32(Console.ReadLine()); for (int i = 1; i <= a; i++) { toplam = toplam + i; } Console.WriteLine("\n\nGirdiiniz Deere Kadar Olan Saylarn Toplam = {0}", toplam); Console.ReadKey();

//Bu program Konsoldan girilen not deerlerinin harf karlklarn ekrana yazdran program.. int not; Console.WriteLine("Notunuzu giriniz(0-100 aras) :"); not = Convert.ToInt32(Console.ReadLine()); if (not < 0 || not > 100) { Console.WriteLine("Yanl not girdiniz.."); } else if(not >= 90) { Console.WriteLine("Notunuz : A -Gayet iyisiniz-"); } else if (not >= 80) { Console.WriteLine("Notunuz : B -Yeterli dzeydesiniz-"); } else if (not>=70) { Console.WriteLine("Notunuz : C -Biraz daha gayret!!..-"); } else if (not >= 50) { Console.WriteLine("Notunuz : D -Bu notu ykseltebilirsin..-"); } else { Console.WriteLine("Dersi Geemediniz.."); } Console.ReadKey();

//bu program konsoldan girilen deerin //15 katn alp ekrana yazyor.. Console.WriteLine("bir sayi giriniz:"); double a = Convert.ToDouble(Console.ReadLine()); double b = a * 15; Console.WriteLine("sayinin 15 kati=" + b); Console.WriteLine("kmak iin bir tua basn.."); Console.ReadKey();

//Bu program dardan girilen saynn iaretini //tespit edip ekrana yazyor... Console.WriteLine("Bir say giriniz...");

int sayi = Convert.ToInt32(Console.ReadLine()); if (sayi < 0) { Console.WriteLine("Girilen sayi negatif"); Console.Write("kmak iin bir tua basnz..."); Console.ReadKey(); } else { Console.WriteLine("Girilen sayi pozitif"); Console.Write("kmak iin bir tua basnz..."); Console.ReadKey();

//girilen_sayinin2katinial_sifirda_cik_ekrandan int sayi; do { Console.WriteLine("sayy giriniz"); sayi = Int32.Parse(Console.ReadLine()); int ikikati = sayi * 2; Console.WriteLine("Saynn iki kat =" + ikikati); } while (sayi != 0);

//Dardan girilen sayy ekrana yazan program. Console.WriteLine("ltfen saymz girelim"); int say = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("girmi olduunuz say = " + say); Console.ReadKey();

//Bu program 4 ilem yapan bir program if-else ile.. int sayi1, sayi2; string islem; Console.WriteLine("Birinci Sayy Girin :"); sayi1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("kinci Sayy Girin :"); sayi2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(" Console.WriteLine(" Console.WriteLine(" Console.WriteLine(" \n \n \n \n Toplama iin karma iin arpma iin Blme iin ---> ---> ---> ---> t'ye c'ye m'ye b'ye basn.."); basn.."); basn.."); basn..");

Console.Write("leminizi seiniz : "); islem = Console.ReadLine(); if (islem == "b") { if (sayi2 != 0) { float sonuc = (float)sayi1 / (float)sayi2; Console.WriteLine("Sonu : {0} ", sonuc); } else { Console.WriteLine("Blen Sfr Olamaz.."); } } else if (islem == "t") {

Console.WriteLine("Sonu : {0}", sayi1 + sayi2); } else if (islem == "m") { Console.WriteLine("Sonu : {0}", sayi1 * sayi2); } else { Console.WriteLine("Sonu : {0}", sayi1 - sayi2); } Console.WriteLine(" by rcpky"); Console.ReadKey();

//Hesap_Makinesi_switch_case int sayi1, sayi2; string islem; Console.WriteLine("lk sayy girin :"); sayi1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("kinci sayy girin :"); sayi2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(" Console.WriteLine(" Console.WriteLine(" Console.WriteLine(" \n \n \n \n Toplama iin karma iin arpma iin Blme iin ---> ---> ---> ---> t'ye c'ye m'ye b'ye basn.."); basn.."); basn.."); basn..");

Console.Write("leminizi seiniz : "); islem = Console.ReadLine(); switch (islem) { case "t": { Console.WriteLine("Sonu : {0}", sayi1 + sayi2); break; } case "m": { Console.WriteLine("Sonu : {0}", sayi1 * sayi2); break; } case "c": { Console.WriteLine("Sonu : {0}", sayi1 - sayi2); break; } case "b": switch (sayi2) { case 0: Console.WriteLine("Blen Say Sfr Olamaz.."); break; default : float sonuc = (float)sayi1 / (float)sayi2; Console.WriteLine("Sonu : {0}", sonuc); break; } break; } Console.ReadKey();

//hesap_makinesiGelismis

Console.WriteLine("Birinci sayy giriniz:"); int s1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("kinci sayy giriniz.."); int s2 = Convert.ToInt32(Console.ReadLine()); int i; for (i=1 ; i<190 ; i++) { int sonuc = 0; Console.WriteLine("\n"); Console.WriteLine("Toplama iin 1, karma iin 2, arpma iin 3,\nBlme iin iin 4, kmak iin 5'e basnz.."); int a = Convert.ToInt32(Console.ReadLine()); if (a == 1) sonuc = s1 + s2; if (a == 2) sonuc = s1 - s2; if (a == 3) sonuc = s1 * s2; if (a == 4) sonuc = s1 / s2; if (a == 5) break; Console.WriteLine("Sonucumuz = " + sonuc); Console.WriteLine("lemlerinize devam etmek iin bir tua basn.."); Console.WriteLine("\n"); Console.ReadKey();

//Bu program konsoldan girilen karekter katarnn boyutunu verir.. Console.WriteLine("Karekter katar girin:"); string s = Console.ReadLine(); int a = s.Length; Console.WriteLine("Karekter katarnn boyutu : " +a); Console.ReadKey();

class Program { //Metot oluturma.. static void Main(string[] args) { yaz("Merhaba"); } static void yaz(string yazi) { Console.WriteLine(yazi); Console.WriteLine("\n\nkmak iin bir tua basnz.."); Console.ReadKey(); } }

class Program { //Metotlarn geriye bilgi dndrmesi.. static void Main(string[] args) { double ucret = 350.22; double ikramiye = 210.35; double sonuc = topla(ucret, ikramiye); string son = "Toplam = " +sonuc.ToString(); yaz(son); } static void yaz(string yazi) { Console.WriteLine(yazi); Console.ReadKey(); } static double topla(double x, double y) { return x + y;

} }

Console.WriteLine("Konsoldan girilen 5 adet saynn 10'dan byk olanlarn sayan program"); int ondanbuyuk = 0; for (int i = 1; i <= 5; i++) { Console.WriteLine(i + ". sayy girin.."); int sayi = Int32.Parse(Console.ReadLine()); if (sayi > 10) ondanbuyuk++; } Console.WriteLine("Ondan byk say adeti = " + ondanbuyuk); Console.ReadKey();

class Program { //parametre olarak dizi degisken kullanimi static void Main(string[] args) { double[] skor={3.5, -65.8, 2.4, 0.55}; yaz(skor); } static void yaz(double[] yazi) { for (int i = 0; i < yazi.Length; i++) { Console.WriteLine(yazi[i]); Console.ReadKey(); } } }

//tip deikenler string benimadimbu; benimadimbu = "RECEP KAYA"; int sayi; sayi = 56; Console.WriteLine("tanmlanan string(karakter) deeri"); Console.WriteLine(benimadimbu); Console.WriteLine("tanmlanan say(integer) deeri"); Console.WriteLine(sayi); Console.WriteLine("kmak iin bir tua basnz.."); Console.ReadKey();

//Byk-Kk harf ayrm int UCRET = 100; int ucret; ucret = 500; Console.WriteLine(UCRET); Console.WriteLine(ucret); Console.ReadKey();

//Ya 13 ie 15 arasnda olanlarn says Console.WriteLine("30 kiilik snfta, ya 13 ile 15 arasnda olanlarn saysn bulan program.."); int aralik = 0; for (int i = 1; i <= 24; i++) { Console.WriteLine(i + ". rencinin yan giriniz.."); int yas = Int32.Parse(Console.ReadLine()); if ((yas >= 32) || (yas <= 15)) aralik++; } Console.WriteLine("Ya 13 ie 15 arasnda olanlarn says = " + aralik); Console.ReadLine();

You might also like