II-BOB. MANTIQIY AMALLARNING AMALIY ASOSLARI




Download 82,33 Kb.
bet4/4
Sana15.05.2024
Hajmi82,33 Kb.
#235655
1   2   3   4
Bog'liq
Kurs ishi

II-BOB. MANTIQIY AMALLARNING AMALIY ASOSLARI


2.1-Mavzu: Mantiqiy amallarga oid masalalar uchun sinf va metodlar yaratish
Arifmetik amallarga oid dasturlar:
C# dasturlash tilida yig’indini ayirma kupaytma hamda bulinmani hisoblashga oid dasturini quyidagicha tuzamiz
using System;
namespace Mantiqiy_amallar{
class qushish_amali {}
class Program
{
static void Main()
{
// Ikki sonni foydalanuvchi kiritadi
Console.WriteLine("Ikkita sonni kiriting:");
Console.Write("Birinchi son: ");
int son1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Ikkinchi son: ");


int son2 = Convert.ToInt32(Console.ReadLine());

// Yig'indini hisoblash va natijani chiqarish


int yigindi = son1 + son2;
Console.WriteLine("Natija: " + yigindi);
}
}
class ayirish_amali { }
class Program
{
static void Main()
{
// Ikki sonni foydalanuvchi kiritadi
Console.WriteLine("Ikkita sonni kiriting:");
Console.Write("Birinchi son: ");
int son1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Ikkinchi son: ");


int son2 = Convert.ToInt32(Console.ReadLine());

// Yig'indini hisoblash va natijani chiqarish


int ayirma = son1 - son2;
Console.WriteLine("Natija: " + ayirma);
}
}
class kupaytma_amali { }
class Program
{
static void Main()
{
// Ikki sonni foydalanuvchi kiritadi
Console.WriteLine("Ikkita sonni kiriting:");
Console.Write("Birinchi son: ");
int son1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Ikkinchi son: ");


int son2 = Convert.ToInt32(Console.ReadLine());

// Yig'indini hisoblash va natijani chiqarish


int kupaytma = son1 * son2;
Console.WriteLine("Natija: " + kupaytma);
}
}
class bulish_amali { }
class Program
{
static void Main()
{
// Ikki sonni foydalanuvchi kiritadi
Console.WriteLine("Ikkita sonni kiriting:");
Console.Write("Birinchi son: ");
int son1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Ikkinchi son: ");


int son2 = Convert.ToInt32(Console.ReadLine());

// Yig'indini hisoblash va natijani chiqarish


int bulish = son1 / son2;
Console.WriteLine("Natija: " + bulish);
}
}
}
Download 82,33 Kb.
1   2   3   4




Download 82,33 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



II-BOB. MANTIQIY AMALLARNING AMALIY ASOSLARI

Download 82,33 Kb.