6. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
Console
.Write(
"n = "
);
int
n =
int
.Parse(
Console
.ReadLine());
int
num = 1;
int
sum = 1;
Console
.Write(
"The sum 1"
);
while
(num < n)
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
165
{
num++;
sum += num;
Console
.Write(
" + "
+ num);
}
Console
.WriteLine(
" = "
+ sum);
}
}
}
a) n tub sonmi yoki yo‘qligini tekshiradi
b) Kompilyatsiya xatoligi vujudga keladi
s) 0
d) 1
7. while (true)
{
Operatorlar;
}
Bu opreator nima deb ataladi
e) Oddiy sikl opreatori
f) Cheksiz sikl operatori
g) Shartli sikl opreatori
h)
True
sikl opreatori
8. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
166
{
class
Program
{
static
void
Main(
string
[] args)
{
int
n =
int
.Parse(
Console
.ReadLine());
decimal
factorial = 1;
while
(
true
)
{
if
(n <= 1)
{
break
;
}
factorial *= n;
n--;
}
Console
.WriteLine(
"n! = "
+ factorial);
}
}
}
a) Faktorialni hisoblash programmasi
b) Kompilyatsiya xatoligi vujudga keladi
s) n=3 kiritsak, n!= 6 natijani qaytaradi
d) a) va s) javoblar to‘g‘ri
9. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
167
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
int
n = 5;
decimal
factorial = 1;
while
(
true
)
{
if
(n <= 1)
{
break
;
}
factorial *= n;
n--;
}
Console
.WriteLine(factorial);
}
}
}
a) n!=120
b) Kompilyatsiya xatoligi vujudga keladi
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
168
s) 120
d) Unknown number!
10. Do - while sikl operatori while sikl operatorini farqi nimada.
a) Do - while sikl operatori while sikliga o‘xshash, lekin u siklning shart
qismini tana qismini bajarib bo‘lganidan keyin tekshiradi
b) while sikl operatori Do - while sikliga o‘xshash, lekin u siklning shart
qismini tana qismini bajarib bo‘lganidan keyin tekshiradi
c) Bu sikl operatorlarni hech qanday farqi yo‘q
d) To‘g‘ri javob berilmagan
11.Do - while sikli qaysi blok sxemadagidek ish bajaradi.
a)
b)
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
169
c)
d) To‘g‘ri
javob
berilmagan
12.Katta sonlar bilan ishlashda qaysi tipdan foydalaniladi
a) BigInteger
b) Integer
c) Numerics
d) BigDecimal
13.BigInteger dan foydalanish uchun qaysi kutubxonani qo‘shishimiz kerak
a) Reference.dll
b) System.Numeric.dll
c) System.IO.dll
d) System.Numerics.dll
14. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
170
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
int
n =0;
int
m =5;
int
num = n;
long
product = 1;
do
{
product *= num;
num++;
}
while
(num <= m);
Console
.WriteLine(product);
}
}
}
a) 1
b) 0
c) 120
d) 125
For sikli qaysi blok sxemadagidek ish bajaradi
a)
b)
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
171
c)
d)
To‘g‘ri
javob
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
172
berilmagan
15.Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
for
(
int
i = 0; i <= 10; i++)
{
Console
.Write(i +
" "
);
}
}
}
}
a) 0 1 2 3 4 5 6 7 8 9 10
b) 0 1 2 3 4 5 6 7 8 9
s) Kompilyatsiya xatoligi vujudga keladi
d) 1 2 3 4 5 6 7 8 9 10
16. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System.Collections.Generic;
using
System.Linq;
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
173
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
for
(
int
i = 1, sum = 1; i <= 128; i = i * 2, sum += i)
{
Console
.WriteLine(
"i={0}, sum={1}"
, i, sum);
}
}
}
}
a) i=1, sum=1
i=2, sum=3
i=4, sum=7
i=8, sum=15
i=16, sum=31
i=32, sum=63
i=64, sum=127
i=128, sum=255
b) i=2, sum=3
i=4, sum=7
i=8, sum=15
i=16, sum=31
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
174
i=32, sum=63
i=64, sum=127
i=128, sum=255
s) i=1, sum=1
i=2, sum=3
i=4, sum=7
i=8, sum=15
i=16, sum=31
i=32, sum=63
i=64, sum=127
d) Kompilyatsiya xatoligi vujudga keladi
17. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
int
n = 5;
int
m = 2;
decimal
result = 1;
for
(
int
i = 0; i < m; i++)
{
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
175
result *= n;
}
Console
.WriteLine(
"{0}^{1} = {2}"
, n, m, result);
}
}
}
a) n^m =25
b) 2^5 =32
s) Kompilyatsiya xatoligi vujudga keladi
d) 5^2 =25
18. Quyidagi kodning kompilyatsiya va ijro natijasi qanday bo‘ladi:
using
System;
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
FirstProgramm
{
class
Program
{
static
void
Main(
string
[] args)
{
for
(
int
small = 1, large = 5; small < large; small++, large--)
{
Console
.WriteLine(small +
" "
+ large);
}
Console
.ReadKey();
}
}
Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
176
}
a) 1 10
2 9
b) 3 8
4 7
s) Kompilyatsiya xatoligi vujudga keladi
d) 1 10 2 9
Do'stlaringiz bilan baham: |