19 Kasım 2009 Perşembe

C# Diziler, İki Martrisin Toplanması

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// 2*3 boyutundaki elemanları klavyeden girilen
// iki marisin toplanması ve sonuç matrisin ekrana yazdırılması

int[,] A = new int[2, 3];
int[,] B = new int[2, 3];
int[,] C = new int[2, 3];

for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write("A matrisinin {0} satır {1} sutun değerini giriniz: ", i+1, j+1);
A[i, j] = Int32.Parse(Console.ReadLine());
}
}

for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write("B matrisinin {0} satır {1} sutun değerini giriniz: ", i + 1, j + 1);
B[i, j] = Int32.Parse(Console.ReadLine());
}
}

for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
C[i, j] = A[i, j] + B[i, j];
Console.Write("{0} ", C[i, j]);
}
Console.WriteLine();
}

}
}
}

C# Diziler, Dizi Sıralama

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Tamsayı dizisi içindeki değerleri büyükten küçüğe doğru sıralayan program

int[] not = { 10, 3, -5, 8, 80, 65, 35, 70 };
int gecici;

for (int i = 0; i < 7; i++)
{
for (int j = i + 1; j <= 7; j++)
{
if (not[i] < not[j])
{
gecici = not[j];
not[j] = not[i];
not[i] = gecici;
}
}
}
for (int i = 0; i <= 7; i++)
{
Console.WriteLine("{0}", not[i]);
}
}
}
}

C# Diziler, İki Martrisin Toplanması

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// 2*3 boyutundaki iki marisin toplanması ve sonuç matrisin ekrana yazdırılması

int[,] A = { { 10, 20, 5 }, { 23, 5, 8 } };
int[,] B = { { 11, 2, 5 }, { 3, 15, 18 } };
int[,] C = new int[2,3];

for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
C[i, j] = A[i, j] + B[i, j];
Console.Write("{0} ", C[i, j]);
}
Console.WriteLine();
}

}
}
}

C# İki Boyutlu Diziler

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// İki boyutlu dizinin elemanlarının ekrana yazdırılması

int[,] not = new int[2,3];

not[0, 0] = 100;
not[0, 1] = 40;
not[0, 2] = 25;
not[1, 0] = 50;
not[1, 1] = 80;
not[1, 2] = 60;

for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++) Console.Write("{0} ", not[i, j]);
Console.WriteLine();
}

}
}
}

C# Switch Döngüsü, YTL, TL Çevirme Programı

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
/* TL'den YTL'ye YTL'den TL'ye Dönüşüm Yapan rogram
*
* 1- TL'den YTL'ye Dönüşüm
*
* YTL = TL / 1000000;
* YKR = (TL % 1000000)/10000;
*
* 2- YTL'den TL'ye Dönüşüm
*
* TL = YTL * 1000000 + YKR * 10000;
*
*/

string Secim;
int paraYKR;
long paraTL, paraYTL;

Console.WriteLine("(1)- TL'den YTL'ye Dönüşüm");
Console.WriteLine("(2)- YTL'den TL'ye Dönüşüm");
Console.WriteLine();
Console.Write("Seçiminizi Giriniz [1/2]: ");
Secim = Console.ReadLine();
Console.WriteLine();

switch (Secim)
{
case "1":
Console.Write("TL'yi Giriniz: ");
paraTL = Int64.Parse(Console.ReadLine());

paraYTL = paraTL / 1000000;
paraYKR = Convert.ToInt32(Math.Round((double) (paraTL % 1000000) / 10000,2));

Console.WriteLine("{0} TL = {1} YTL ve {2} YKR'dir", paraTL, paraYTL, paraYKR);
break;

case "2":
Console.Write("YTL Kısmını Giriniz: ");
paraYTL = Int64.Parse(Console.ReadLine());

Console.Write("YKR Kısmını Giriniz: ");
paraYKR = Int32.Parse(Console.ReadLine());

paraTL = paraYTL * 1000000 + paraYKR * 10000;
Console.WriteLine("{0} YTL, {1} YKR = {2} TL'dir.", paraYTL, paraYKR, paraTL);

break;
default:
Console.WriteLine("Yanlış Seçim Yaptınız!...");
break;
}
}
}
}

C# Switch Döngüsü

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int gun;

Console.Write("Gün Numarasını Giriniz: ");
gun = Int32.Parse(Console.ReadLine());
Console.WriteLine();

switch (gun)
{
case 1:
Console.WriteLine("Pazartesi");
break;
case 2:
Console.WriteLine("Salı");
break;
case 3:
Console.WriteLine("Çarşamba");
break;
case 4:
Console.WriteLine("Perşembe");
break;
case 5:
Console.WriteLine("Cuma");
break;
case 6:
Console.WriteLine("Cmartesi");
break;
case 7:
Console.WriteLine("Pazar");
break;
default:
Console.WriteLine("Yanlış Seçim Yaptınız!...");
break;

}




}
}
}

C# While Döngüsü

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// 0-100 arasındaki çift sayıların toplamını bulan program

int i = 0;
int toplam = 0;

do
{
toplam += i;
i += 2;

} while (i <= 100);

Console.WriteLine("0-100 arasındaki çift sayıların toplamı: {0}", toplam);
}
}
}

C# While Döngüsü

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// 0-100 arasındaki tek sayıların toplamını bulan program

int i = 1;
int toplam = 0;

while (i <= 100)
{
toplam += i;
i += 2;
}

Console.WriteLine("0-100 arsındaki tek sayıların toplamı: {0}", toplam);

}
}
}

C# ++ Ve - - Operatörlerinin Kullanımı

using System;
using System.Collections.Generic;
using System.Text;

namespace forOrnek
{
class Program
{
static void Main(string[] args)
{
// ++ ve -- unary operatörlerinin kullanımı

int x, y;

y = 5;
x = y++ * 2;
Console.WriteLine("x = y++ * 2 işleminden sonra y = {0} ve x = {1}", y, x);

y = 5;
x = ++y * 2;
Console.WriteLine("x = ++y * 2 işleminden sonra y = {0} ve x = {1}", y, x);

y = 5;
x = y-- * 2;
Console.WriteLine("x = y-- * 2 işleminden sonra y = {0} ve x = {1}", y, x);

y = 5;
x = --y * 2;
Console.WriteLine("x = --y * 2 işleminden sonra y = {0} ve x = {1}", y, x);

}
}
}

C# For Döngüsü

using System;
using System.Collections.Generic;
using System.Text;

namespace forOrnek
{
class Program
{
static void Main(string[] args)
{
// *
// **
// ***
// ****
// *****

int i, j;

for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}

}
}
}

C# For Döngüsü

using System;
using System.Collections.Generic;
using System.Text;

namespace forOrnek
{
class Program
{
static void Main(string[] args)
{
// 1
// 12
// 123
// 1234
// 12345

int i, j;

for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("{0}", j);
}
Console.WriteLine();
}

}
}
}

C# Taban Aritmetiği Programı

using System;
using System.Collections.Generic;
using System.Text;

namespace forOrnek
{
class Program
{
static void Main(string[] args)
{
// üs ve taban klavyeden girilecek
// Örneğin 5 ve 3 girilmişse 5 üzeri 3 değeri bulunacak

int i, us, taban, sonuc=1;
string strUs, strTaban;

Console.Write("Üs değerini giriniz: ");
strUs = Console.ReadLine();
us = Int32.Parse(strUs);

Console.Write("Taban değerini giriniz: ");
strTaban = Console.ReadLine();
taban = Int32.Parse(strTaban);

for (i = 1; i <= us; i++)
{
sonuc *= taban;

}
Console.WriteLine("{0} ın {1} kuvveti = {2}", taban, us, sonuc);
}
}
}

C# 0-100 Arasındaki Tek Sayıların Toplamını Bulan Program

using System;
using System.Collections.Generic;
using System.Text;

namespace forOrnek
{
class Program
{
static void Main(string[] args)
{
// 0-100 arasındaki tek sayıların toplamını bulan program

int i, toplam=0;

for (i = 1; i <= 100; i += 2)
{
toplam += i;

}
Console.WriteLine("0-100 arasındaki tek sayıların toplamı: {0}", toplam);
}
}
}

C# Vize, Final, Not Harfi Hesaplama

using System;
using System.Collections.Generic;
using System.Text;

namespace Ornek
{
class Program
{
static void Main(string[] args)
{
// Klavyeden girilen vize ve final notuna göre öğrencinin geçme notunu
// hem rakamla hem de harfle yazan programı yazınız.

int vize, final, ort;
string strVize, strFinal;

Console.Write("Vize notunu giriniz: ");
strVize = Console.ReadLine();
vize = Int32.Parse(strVize);

Console.Write("Final notunu giriniz: ");
strFinal = Console.ReadLine();
final = Int32.Parse(strFinal);

ort = Convert.ToInt32(vize * 0.4 + final * 0.6);

// 90 - 100 AA
// 80 - 90 AB
// 70 - 80 BB
// 60 - 70 BC
// 50 - 60 CC
// 40 - 50 DC
// 0 - 40 FF

Console.WriteLine();

if (ort >= 90 && ort <= 100) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: AA", ort); else if (ort >= 80 && ort < 90) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: AB", ort); else if (ort >= 70 && ort < 80) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: BB", ort); else if (ort >= 60 && ort < 70) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: BC", ort); else if (ort >= 50 && ort < 60) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: CC", ort); else if (ort >= 40 && ort < 50) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: DC", ort); else if (ort >= 0 && ort < 40) Console.WriteLine("Geçme Notu Rakamla: {0} Harfle: FF", ort);

}
}
}

C# ! İlişkisel Operatörü

using System;

namespace Ornek
{
class Program
{
static void Main()
{
bool a, b;

a = true;
Console.WriteLine("! {0} = {1}",a,!a);

a = false;
Console.WriteLine("! {0} = {1}", a, !a);

}
}
}

// ! ilişkisel operatörü

C# || İlişkisel Operatörü

using System;

namespace Ornek
{
class Program
{
static void Main()
{
bool a, b;

a = true;
b = true;
Console.WriteLine("{0} || {1} = {2}",a,b,a || b );

a = true;
b = false;
Console.WriteLine("{0} || {1} = {2}", a, b, a || b);

a = false;
b = true;
Console.WriteLine("{0} || {1} = {2}", a, b, a || b);

a = false;
b = false;
Console.WriteLine("{0} || {1} = {2}", a, b, a || b);

}
}
}

// || ilişkisel operatörü

C# && İlişkisel Operatörü

using System;

namespace Ornek
{
class Program
{
static void Main()
{
bool a, b;

a = true;
b = true;
Console.WriteLine("{0} && {1} = {2}",a,b,a && b );

a = true;
b = false;
Console.WriteLine("{0} && {1} = {2}", a, b, a && b);

a = false;
b = true;
Console.WriteLine("{0} && {1} = {2}", a, b, a && b);

a = false;
b = false;
Console.WriteLine("{0} && {1} = {2}", a, b, a && b);

}
}
}

// && ilişkisel operatörü

C# Haftanın Günlerini Yazdırma

using System;

namespace Ornek
{
class Program
{
static void Main()
{
int gun;
string strGun;

Console.Write("Gün numarasını giriniz :");
strGun = Console.ReadLine();
gun = Int32.Parse(strGun);

if (gun == 0) Console.WriteLine("Pazartesi");
if (gun == 1) Console.WriteLine("Salı");
if (gun == 2) Console.WriteLine("Çarşamba");
if (gun == 3) Console.WriteLine("Perşembe");
if (gun == 4) Console.WriteLine("Cuma");
if (gun >= 5 && gun<=6) Console.WriteLine("Hafta Sonu");

}
}
}

// Haftanın günlerini yazan program

C# Klavyeden Girilen Değeri Ekrana Yazan Program

using System;

namespace Ornek
{
class Program
{
static void Main()
{
int sayi;
string strSayi;

strSayi = Console.ReadLine();
sayi = Int32.Parse(strSayi);

Console.WriteLine("sayi değişkeninin değeri = {0}",sayi);
}
}
}

// Klavyeden girilen sayıyı ekrana yazan program

C# Değişkene Değer Atama, Yazdırma

using System;

namespace Ornek
{
class Program
{
static void Main()
{
int a, b;
a = 5;
b = 10;

Console.WriteLine("a değişkeninin değeri = {0}, b değişkeninin değeri = {1}",a,b);
}
}
}

C# Aritmetik İşlemler, C# Toplama, C# Çıkarma, C# Çarpma, C# Bölme, C# Modülüs Bölme

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main()
{
int sayi1,sayi2;
string strSayi1,strSayi2;
String islem;
Console.Write("1.Sayıyı Giriniz:");
strSayi1=Console.ReadLine();
Console.Write ("2.Sayıyı Giriniz:");
strSayi2=Console.ReadLine();
sayi1=Int32.Parse (strSayi1);
sayi2=Int32.Parse (strSayi2);

Console.WriteLine("\n");
Console.WriteLine("İşlemler");
Console.WriteLine("--------------");
Console.WriteLine("(1)+ Toplama");
Console.WriteLine("(2)- Çıkarma");
Console.WriteLine("(3)* Çarpma");
Console.WriteLine("(4)/ Bölme");
Console.WriteLine("(5)% Modülüs Bölme");
Console.WriteLine("\n");

Console.WriteLine("İslem Seçiniz");
islem = Console.ReadLine();

if (islem == "1") Console.WriteLine("{0}+{1}={2}", sayi1, sayi2, sayi1 + sayi2);
if (islem == "2") Console.WriteLine("{0}-{1}={2}", sayi1, sayi2, sayi1 - sayi2);
if (islem == "3") Console.WriteLine("{0}*{1}={2}", sayi1, sayi2, sayi1 * sayi2);
if (islem == "4") Console.WriteLine("{0}/{1}={2}", sayi1, sayi2, sayi1 / sayi2);
if (islem == "5") Console.WriteLine("{0}%{1}={2}", sayi1, sayi2, sayi1 % sayi2);


}
}
}

2 Kasım 2009 Pazartesi

C# True False, C Sharp True False

using System;

using System.Collections.Generic;
using System.Text;
namespace True_False_Read
{
class Program
{
static void Main(string[] args)
{
basla:
string s;
bool a1, b1;//a1,b1 bool (doğru-yanlış)tanımlama

string a, b;//a,b string tanımlama

Console.WriteLine();

Console.Write("B Değeri=");

a=Console.ReadLine();//a string eğerini gir

Console.Write("A Değeri=");

b=Console.ReadLine();//b string değerini gir

a1 = bool.Parse(a);//a string değerini bool'e çevir

b1 = bool.Parse(b);//b string değerini bool'e çevir

Console.WriteLine("{0} && {1} = {2}", a1, b1, a1 && b1);//A ve B 'nin Değeri

Console.WriteLine("{0}

{1} = {2}", a1, b1, a1

b1);//A veya B 'nin Değeri

Console.WriteLine("!{0} = {1}", a1, !a1);//A'nın Değili

Console.ReadLine();

goto basla;//Yeniden başla

}
}
}

C# Vize, Final, Ortalama ve Harf Hesabı, C Sharp Vize, Final, Ortalama

using System;

using System.Collections.Generic;
using System.Text;
namespace VizeFinalOrtHarf

{

class Program

{

static void Main(string[] args)

{

int Vize, Final;

string strVize, strFinal;

float Ort;
Console.Write("Vize Notunu Giriniz=");
strVize = Console.ReadLine();
Vize = Int32.Parse(strVize);
Console.Write("Final Notunu Giriniz=");
strFinal = Console.ReadLine();
Final = Int32.Parse(strFinal);
Ort = Vize * 0.4f + Final * 0.6f;
Console.WriteLine("Geçme Notu={0}",Ort);
if (Ort >= 89.5 && Ort < 100) Console.WriteLine("Geçme Harfi = AA");
else if (Ort >= 79.5 && Ort < 89.5) Console.WriteLine("Geçme Harfi = BA");
else if (Ort >= 69.5 && Ort < 79.5) Console.WriteLine("Geçme Harfi = BB");
else if (Ort >= 59.5 && Ort < 69.5) Console.WriteLine("Geçme Harfi = CB");
else if (Ort >= 49.5 && Ort < 59.5) Console.WriteLine("Geçme Harfi = CC");
else if (Ort >= 39.5 && Ort < 49.5) Console.WriteLine("Geçme Harfi = DC");
if (Ort >= 0 && Ort < 39.5) Console.WriteLine("Geçme Harfi = FF");
}
}
}

14 Ekim 2009 Çarşamba

Menü Seçimli C# Hesaplama Programı, Menü Seçimli C Sharp Hesap Programı

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int topla, cikar, carp,bir,iki,modul;
float bol;
string secimal,biri,ikisi;
Console.WriteLine("(1) Toplama");
Console.WriteLine("(2) Çıkarma");
Console.WriteLine("(3) Çarpma");
Console.WriteLine("(4) Bölme");
Console.WriteLine("(5) Modüles Bölme");
Console.WriteLine();
Console.Write("Seçiminiz :");
secimal = Console.ReadLine();
Console.Write("1. Sayıyı Giriniz: ");
biri = Console.ReadLine();
bir=Int32.Parse(biri);
Console.Write("2. Sayıyı Giriniz: ");
ikisi=Console.ReadLine();
iki = Int32.Parse(ikisi);
Console.WriteLine();
if (secimal == "1")
{
topla = bir + iki;
Console.WriteLine("{0} + {1} = {2}", bir,iki,topla);
}
if (secimal == "2")
{
cikar = bir - iki;
Console.WriteLine("{0} - {1} = {2}", bir,iki,cikar);
}
if (secimal == "3")
{
carp = bir * iki;
Console.WriteLine("{0} * {1} = {2}", bir,iki,carp);
}
if (secimal == "4")
{
bol= (float)bir / iki;
Console.WriteLine("{0} / {1} = {2}", bir,iki,bol);
}
if (secimal == "5")
{
modul = bir % iki;
Console.WriteLine("{0} % {1} = {2}", bir,iki,modul);
}
}
}
}

13 Ekim 2009 Salı

C# Hesaplama Programı, C Sharp Hesap Programı

using System;
using System.Collections.Generic;
using System.Text;
namespace islem
{
class Program
{
static void Main(string[] args)
{
int Sayi1; //Sayi1 değişkenini tanımlıyoruz
float Sayi2; //Sayi2 değişkenini bölme işleminde ondalıklı olarak sonuç almak için "folat" komutu ile değişkeni tanımlıyoruz


string strSayi1; //strSayi1 değişkenini tanımlıyoruz. Klavye girişi string okuyacaktır.
string strSayi2; //strSayi2 değişkenini tanımlıyoruz. Klavye girişi string okuyacaktır.


Console.Write("A Değişkenin değerini giriniz: "); strSayi1 = Console.ReadLine(); //strSayi1 değişkenine değer giriyoruz.


Console.Write("B Değişkenin değerini giriniz: "); strSayi2 = Console.ReadLine(); //strSayi2 değişkenine değer giriyoruz.


Console.WriteLine(""); // Bir satır boşluk bırakıyoruz.


Sayi1 = Int32.Parse(strSayi1);  // Klavyeden strSayi1 değişkenine girilen değeri Sayi1 olarak int değişkenine çeviriyoruz.


Sayi2 = Int32.Parse(strSayi2); // Klavyeden strSayi2 değişkenine girilen değeri Sayi2 olarak int değişkenine çeviriyoruz.


Console.Write("{0} + {1} = ", Sayi1, Sayi2); Console.WriteLine(Sayi1 + Sayi2); // Değişlenleri toplayıp sonucu yazdırıyoruz.


Console.Write("{0} - {1} = ", Sayi1, Sayi2); Console.WriteLine(Sayi1 - Sayi2); // Değişlenleri çıkarıp sonucu yazdırıyoruz.


Console.Write("{0} / {1} = ", Sayi1, Sayi2); Console.WriteLine(Sayi1/Sayi2); // Değişlenleri bölüp sonucu float ile ondalıklı olarakta yazdırabiliyoruz.


Console.Write("{0} * {1} = ", Sayi1, Sayi2); Console.WriteLine(Sayi1 * Sayi2); // Değişlenleri çarpıp sonucu yazdırıyoruz.


Console.ReadLine(); // Klavye tuşuna basıldığında uygulama kapatılacak.
}
}
}