BOOLEAN.24
A,B,C sonlari berilgan (A soni noldan farqli). D=B^2-4*A*C deskiriminantfan foydalanib ,jumlani rostlikka tekshiring : “A*x^2+B*x+C=0 kvadrat tenglama haqiqiy ildizga ega”.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
double A,B,C,D;
Console.WriteLine("Mulohaza:A*x^2+B*x+C=0 kvadrat tenglama haqiqiy yechimga ega ");
Console.WriteLine("kvadrat tenglamaning koefitsentlarini kiriting : A=");
Console.WriteLine("A=");
A = double.Parse(Console.ReadLine());
Console.WriteLine("B=");
B = double.Parse(Console.ReadLine());
Console.WriteLine("C=");
C = double.Parse(Console.ReadLine());
D = B * B - 4 * A * C;
if(D<0)
Console.WriteLine("Mulohaza yolg'on");
else
Console.WriteLine("Mulohaza rost");
Console.ReadKey();
}
}
}
IF.5
Uchta butun son berilgan . Shu sonlar orasidan nechta musbat va manfiy son borligini aniqlovchi programma tuzing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
int A, B, C, k = 0, m = 0;
Console.WriteLine("Uchta butun son kiriting");
Console.WriteLine("A=");
A = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("B=");
B = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("C=");
C = Convert.ToInt32(Console.ReadLine());
if
(A > 0) k++;
else if
(A < 0) m++;
if
(B > 0) k++;
else if
(B < 0) m++;
if
(C > 0) k++;
else if
(C < 0) m++;
Console.WriteLine("Kiritilgan sonlarning {0}tasi musbat,{1}tasi manfiy",k,m);
Console.ReadKey();
}
}
}
CESE.3
Oy raqami berilgan . Kiritilgan oy qaysi faslga tegishli ekanini chiqaruvchi programma tuzing(Masalan:2-oy , qish).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
int n;
n = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case 1:
Console.WriteLine("Qish"); break;
case 2:
Console.WriteLine("Qish"); break;
case 3:
Console.WriteLine("Bahor"); break;
case 4:
Console.WriteLine("Bahor"); break;
case 5:
Console.WriteLine("Bahor"); break;
case 6:
Console.WriteLine("Yoz"); break;
case 7:
Console.WriteLine("Yoz"); break;
case 8:
Console.WriteLine("Yoz"); break;
case 9:
Console.WriteLine("Kuz"); break;
case 10:
Console.WriteLine("Kuz"); break;
case 11:
Console.WriteLine("Kuz"); break;
case 12:
Console.WriteLine("Qish"); break;
default: Console.WriteLine("Bunday oy mavjud emas"); berak;
}
Console.ReadLine();
}
}
}
FOR.19
n butun soni berilgan (n>0).Birdan n gacha bo’lgan sonlar ko’paytmasini hisoblovchi programma tuzilsin. N!-1*2*3…..*n
Birdan n gacha bo’lgan sonlar ko’paytmasi n factorial deyiladi.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
int n=5,a,i;
n = Convert.ToInt32(Console.ReadLine());
a = Convert.ToInt32(Console.ReadLine());
for (i = 1; i <= n; i++)
{
a *= i;
if (i != n) Console.WriteLine("{0}" + "*", i);
else Console.WriteLine("{0}" + "=", i);
Console.WriteLine(n);
}
Console.ReadKey();
}
}
WHILE.
N va K butun sonlari berilgan . Faqat ayirish va qo’shish ammalarini ishlatib N soni K soniga bo’lgandagi qoldiq va butun qismini aniqlovchi porgramma tuzilsan.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Matrix_9
{
class Program
{
static void Main(string[] args)
{
Random rd = new Random();
int m = Convert.ToInt32(Console.ReadLine());
int n = Convert.ToInt32(Console.ReadLine());
int[,] mt = new int[m, n];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
mt[i, j] = rd.Next( 100);//oraliq qoyib olamiz
Console.Write(mt[i, j] + " ");
}
Console.WriteLine("");
}
Console.WriteLine("");
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write(mt[i, j] + " ");
}
Console.WriteLine("");
i = i + 1;
}
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication19
{
class Program
{
static void Main(string[] args)
{
int a, b;
Console.WriteLine("a sonini kiriting: ");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("b sonini kiriting: ");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Berilgan nuqta: ");
if ((a == 0) && (b == 0)) Console.WriteLine("Koordinata boshida yotadi. ");
if (((a != 0) && (b == 0)) || ((a == 0) && (b != 0))) Console.WriteLine("Koordinata chizig'ida yotadi. ");
if ((a > 0) && (b > 0)) Console.WriteLine("I chorakda yotadi. ");
if ((a < 0) && (b > 0)) Console.WriteLine("II chorakda yotadi. ");
if ((a < 0) && (b < 0)) Console.WriteLine("III chorakda yotadi. ");
if ((a > 0) && (b < 0)) Console.WriteLine("IV chorakda yotadi. ");
Console.WriteLine(" ");
Console.WriteLine("Vazifa bajarildi!!!");
Console.ReadKey();
}
}
}
Do'stlaringiz bilan baham: |