Factorial nomli rekursiv funksiya tuzing. X sonini quyidagi formula yordamida hisoblovchi Formula


Download 53.48 Kb.
bet4/8
Sana16.06.2023
Hajmi53.48 Kb.
#1489108
1   2   3   4   5   6   7   8
Bog'liq
algoritm 29-talik topshiriq javoblari

fasllar nomli tur yarating. swich-case yordamida yil fasllariga qaysi oylar to`g`ri kelishini chiqaruvchi dastur tuzing.

15-savol
Enum kalit so`zi yordamida hafta_kunlari nomli tur yarating. Agar hafta_kunlari turiga mansub qandaydir t o`zgaruvchi yakshanba yoki shanbaga teng bo`lsa ekranga “Dam olish kuni” yozuvi, aks holda “Ish kuni” yozuvi ekranga chiqsin.

enum Hafta_Kunlari


{
Dushanba,
Seshanba,
Chorshanba,
Payshanba,
Juma,
Shanba,
Yakshanba
}

class Program


{
static void Main(string[] args)
{
Hafta_Kunlari dayOfWeek = Hafta_Kunlari.Seshanba;

switch (dayOfWeek)


{
case Hafta_Kunlari.Shanba:
case Hafta_Kunlari.Yakshanba:
Console.WriteLine("Dam olish kuni");
break;
default:
Console.WriteLine("Ish kuni");
break;
}
}
}

16-savol
Talabalar nomli struktura hosil qiling. Ushbu struktura talabalarning ism_familiyasi bilan nomlangan maydonlardan iborat bo`lsin. Talaba strukturasi yordamida 4 ta talabaning 1-semestrda olgan ballarini kiriting. Ballarining o`rtachasi 70 % dan baland bo`lgan talabalar ism familiyasi ekranga chiqsin.

struct Talabalar
{
public string ism_familiya;
public double ball;
}

class Program


{
static void Main(string[] args)
{
Talabalar[] talabalar = new Talabalar[4];

// 4 ta talabaning 1-semestrda olgan ballarini kiritish


talabalar[0].ism_familiya = "Alijonov Alisher";
talabalar[0].ball = 85.5;

talabalar[1].ism_familiya = "Qodirov Qodir";


talabalar[1].ball = 69.5;

talabalar[2].ism_familiya = "Hakimova Hafiza";


talabalar[2].ball = 92.0;

talabalar[3].ism_familiya = "Rasulov Asror";


talabalar[3].ball = 78.0;

// 70% dan baland bo`lgan talabalar ism familiyasi ekranga chiqariladi


foreach (Talabalar talaba in talabalar)
{
if (talaba.ball >= 70)
{
Console.WriteLine(talaba.ism_familiya);
}
}

Console.ReadKey();


}
}

17-savol
Xodim nomli


Download 53.48 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling