Yechilishi:
//1
jasur1();
jasur2();
static void jasur1() {
Console.WriteLine("Assalamu aleykum!!!");
}
static void jasur2()
{
Console.WriteLine("Valeykum assalom!!!");
}
Console.WriteLine();
//2
Console.Write("Ismingiz:");
string a = Convert.ToString(Console.ReadLine());
jasur3(); Console.Write(a);
static void jasur3() {
Console.Write("Assalomu Aleykum ");
}
Console.WriteLine(" "); Console.WriteLine();
//3
Console.Write("birinchi sonni kiriting:");
int x = int.Parse(Console.ReadLine());
Console.Write("ikkinchi sonni kiriting:");
int y = int.Parse(Console.ReadLine());
hisoblash(x,y);
static void hisoblash(int x,int y)
{
Console.WriteLine("Raqamlar yigindisi: " + (x + y));
Console.WriteLine("Raqamlar ayirmasi: " + (x - y));
Console.WriteLine("Raqamlar kopaytmasi: " + (x * y));
Console.WriteLine("Raqamlar bolinmasi: "+(x / y));
}
Console.WriteLine();
//4
Console.Write("Brorta matin kiriting: ");
string matn=Convert.ToString(Console.ReadLine());
char n=' ' ;
if (n == 0) { Console.WriteLine("Matinda bitta soz mavjud."); }
else { Console.WriteLine("Matinda " + (n-1) + " ta soz mavjud."); }
Console.WriteLine();
//5
int[] massiv = new int[4];
Console.Write("Massivning birinchi elementini kiriting:");
int massiv1=int.Parse(Console.ReadLine());
massiv1=massiv[0];
Console.Write("Massivning ikkinchi elementini kiriting:");
int massiv2 = int.Parse(Console.ReadLine());
massiv2 = massiv[1];
Console.Write("Massivning uchinchi elementini kiriting:");
int massiv3 = int.Parse(Console.ReadLine());
massiv1 = massiv[2];
Console.Write("Massivning tortinchi elementini kiriting:");
int massiv4 = int.Parse(Console.ReadLine());
massiv4 = massiv[3];
jasur4(massiv1,massiv2,massiv3,massiv4);
static int jasur4(int massiv1,int massiv2,int massiv3, int massiv4)
{
int c = massiv1 + massiv2 + massiv3 + massiv4;
return c;
}
Console.WriteLine();
//6
Console.Write("q=");
double q=Convert.ToDouble(Console.ReadLine());
Console.Write("w=");
double w = Convert.ToDouble(Console.ReadLine());
jasur5(ref q,ref w);
Console.WriteLine("q="+q);
Console.WriteLine("w="+w);
static void jasur5(ref double q, ref double w )
{
q = q + w;
w = q - w;
q = q - w;
}
Console.WriteLine();
//7
Console.Write("g=");
double g = Convert.ToDouble(Console.ReadLine());
Console.Write("h=");
double h = Convert.ToDouble(Console.ReadLine());
hisoblas(g, h);
static void hisoblas(double g, double h)
{
Console.WriteLine(g + " sonining "
+ h + "-darajasi " +
(Math.Pow(g, h)) +
" ga teng");
}
Console.WriteLine();
//8
Console.Write("k=");
double k = Convert.ToDouble(Console.ReadLine());
fibonachchi(k);
static void fibonachchi(double k)
{
int a1 = 0, a2 = 1;
while (a1 <= k && a2 <= k)
{
Console.WriteLine(a1);
Console.WriteLine(a2);
a1 = a1 + a2;
a2 = a2 + a1;
}
}
Console.WriteLine();
//9
Console.Write("l=");
int l = Convert.ToInt32(Console.ReadLine());
tub(l);
static void tub(int l)
{
int S = 0;
for (int i = 2; i < l; i++)
{
if (l % i == 0) { S++; }
}
if (S == 0) { Console.WriteLine("Bu son haqiqatdan ham tub son"); }
else { Console.WriteLine("Bu son tub son emas"); }
}
Console.WriteLine();
//10
Console.Write("j=");
int j = Convert.ToInt32(Console.ReadLine());
yigindi(j);
static void yigindi(int j)
{
int S = 0;
while (j > 0)
{
S = S + (j % 10);
j = (j - (j % 10)) / 10;
}
Console.WriteLine("Raqamlari yig'indisi: " + S);
}
Console.WriteLine();
//11
Console.Write("t=");
int t = Convert.ToInt32(Console.ReadLine());
yigind(t);
static void yigind(int t)
{
int S = 1;
for (int i = 1; i <= t; i++)
{
S = S * i;
}
Console.WriteLine("{0}!={1}", t, S);
Console.WriteLine();
}
//12
Console.Write("d=");
int d = Convert.ToInt32(Console.ReadLine());
indeks(d);
static void indeks(int d)
{
int a5 = 0, a6 = 1;
int i = 0;
while (i <= d && (i - 1) <= d)
{
if (i == d) { Console.WriteLine("{0} indeksli fibonachchi soni {1} ga teng", d, a5); }
i++;
a5 = a5 + a6;
if (i == d) { Console.WriteLine("{0} indeksli fibonachchi soni {1} ga teng", d, a5); }
i++;
a6 = a6 + a6;
}
}
Console.ReadKey();
Javob:
Do'stlaringiz bilan baham: |