Bilim ve Teknoloji

C Sharp Konsol Uygulamaları Metodlar 2

C Sharp Konsol Uygulamaları Metodlar 2 yazımızda C Sharp üzerinde overclocking yapmak, okul notu toplama, parametre ile işlem, params ve foreach metod ile kullanmayı yazdık.

C Sharp Konsol Uygulamaları Metodlar

C Sharp Konsol Uygulamaları Metodlar Overclocking
Method Overclocking

Method Overclocking Yaparak Main Fonksiyonda Neyi Çağırırsak İlk Önce O Gösterilir

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
class Program
{
static void dizi(int a, int b)
{
int sonuc = a + b;
Console.WriteLine(“ilk parametre ” + sonuc);
Console.ReadLine();
}
static void dizi(int a)
{
Console.WriteLine(“ikinci parametre ” + a);
Console.ReadLine();
}
static void dizi(double a, double b)
{
Console.WriteLine(“üçüncü parametre ” + a * b);
Console.ReadLine();
}
static void Main(string[] args)
{

dizi(4, 2);
dizi(12.5, 15.4);
dizi(5);

}
}
}

C Sharp Konsol Uygulamaları Metodlar Not
Not Toplamı

Okul Not Toplamını Yazan Program (İlkokul, ortaokul, lise farklı)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
class Program
{
static int okul(int a, int b)
{
int sonuc = a + b;
return sonuc;

}
static int okul(int a, int b, int c)
{
int sonuc = a + b + c;
return sonuc;

}
static int okul(int a, int b, int c, int d)
{
int sonuc = a + b + c + d;
return sonuc;

}
static void Main(string[] args)
{

Console.WriteLine(“Hangi okuldasın”);
Console.WriteLine(“1-İlkokul”);
Console.WriteLine(“2-ortaokul”);
Console.WriteLine(“3-lise”);
int secim = Convert.ToInt32(Console.ReadLine());
switch (secim)
{
case 1:
Console.WriteLine(“Puan gir “);
int puan = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Sözlü gir “);
int sozlu = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Sonuç=” + okul(puan, sozlu));
break;

case 2:

Console.WriteLine(“Puan gir “);
puan = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Sözlü gir “);
sozlu = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“2.Sözlü gir “);
int sozlu1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Sonuç=” + okul(puan, sozlu, sozlu1));
break;

case 3:
Console.WriteLine(“Puan gir “);
puan = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Sözlü gir “);
sozlu = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“2.Sözlü gir “);
sozlu1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Kanaat gir “);
int kanaat = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Sonuç=” + okul(puan, sozlu, sozlu1, kanaat));
break;

default:
break;
}
Console.ReadLine();
}
}
}

C Sharp Konsol Uygulamaları Metodlar Sayı
Toplama ve Çarpma İşlemi

Değişken Sayıda Parametre Alan Toplama ve Çarpma İşlemi-C Sharp Konsol Uygulamaları Metodlar

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ekim142016
{
class Program
{

static int Toplama(params int[] liste)
{
int toplam = 0;
foreach (int deger in liste)
{
toplam += deger;
}
return toplam;
}
static int Carpim(params int[] liste)
{
int sonuc = 1;
foreach (int deger in liste)
{
sonuc *= deger;
}
return sonuc;
}
static void Main(string[] args)
{

Console.WriteLine(“5+10+8={0}”, Toplama(5, 10, 8));
Console.WriteLine(“5+10+8={0}”, Carpim(5, 10, 8));
Console.WriteLine(“10+25+400+221={0}”, Toplama(10, 25, 400, 221));
Console.WriteLine(“1*2*3*4*5*6*7*8={0}”, Carpim(1, 2, 3, 4, 5, 6, 7, 8));
Console.ReadKey();
}
}
}

Params
En Büyük ve En Küçük Sayı

Bir Dizinin İçindeki 10 Sayıdan Params Kullanarak En Büyük ve En Küçük Sayıyı Bulma

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ekim142016
{
class Program
{

static void SeriDizi(params int[] liste)
{

Console.WriteLine(“En büyük sayı ” + liste.Max());
Console.WriteLine(“En küçük sayı ” + liste.Min());
}

static void Main(string[] args)
{
int[] dizi = { 1, 5, 7, 45, 34, 65, 34, 76, 4, 100 };
SeriDizi(dizi);
Console.ReadKey();
}
}
}

Params ve Foreach
Sayılar

40’a Kadar Olan Sayıların 5 ve 7’ye Bölünmeyenlerini Params ve Foreach İle Ekrana Yazdırma

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int[] dizi = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 2, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 };
Bolunen(dizi);
Console.ReadKey();

}
static void Bolunen(params int[] liste)
{
foreach (int sayilar in liste)
{
if (sayilar % 5 != 0 && sayilar % 7 != 0)
{
Console.WriteLine(sayilar);
}

}

}
}
}

Microsoft C Sharp Konsol Uygulamaları Metodlar 2.

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir