Guruh: ki-s22-06 Bajardi Amaliy ish-4

|
Guruh: ki-s22-06 Bajardi
|
bet | 1/2 | Sana | 22.12.2023 | Hajmi | 1,33 Mb. | | #126808 |
Bog'liq Amaliy ish-4
O`ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI
UNIVERSITETI SAMARQAND FILIALI
"Dasturlash 1” fanidan
AMALIY ISH
№4
Guruh: KI-S22-06
Bajardi: MELIYEV M.
Qabul qildi: G‘OZIYEV X.
SAMARQAND – 2023
Test
1. Quyidagi satrlarni tahlil qiling:
double sum = 0;
for (double d = 0; d < 10;)
{
d += 0.1;
sum += sum + d;
}
A.Ushbu dasturda kompilyatsiya xatolik ko`rsatadi , chunki for siklida davomiylik qiymati yo`q.
B. Dasturning kompilyatsiya xatosi bor, chunki for stklidagi nazorat o'zgaruvchisi ikkilangan turdagi bo'lishi mumkin emas.
C. Dastur xech qachon xatolik ko`rsatmaydii, chunki d <10 har doim to'g'ri bo'ladi.
D.Dastur to`liq kompilyatsiya bo`ladi va ishlaydi.
2. Quyidagi sikllardan qaysi biri "C ++ ga xush kelibsiz" deb 10 martaekranga bosib chiqaradi?
A:
for (int count = 1; count <= 10; count++)
{
cout << "Welcome to C++" << endl;
}
B:
for (int count = 0; count < 10; count++)
{
cout << "Welcome to C++" << endl;
}
C:
for (int count = 1; count < 10; count++)
{
cout << "Welcome to C++" << endl;
}
D:
for (int count = 0; count <= 10; count++)
{
cout << "Welcome to C++" << endl;
}
A. BD
B. ABC
C. AC
D. BC
E. AB
3.
Quyidagi siklda ekranga _______________ chiqadi.
for (int i = 1; i <= 10; i++)
{
cout << i << " ";
i++;
}
1 2 3 4 5 6 7 8 9
B. 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5
1 3 5 7 9
1 4 6 8 10
4.Quyidagi sikllardan qaysi biri 1/2 + 2/3 + 3/4 + ... + 99/100 ifodani hisoblab chiqadi?
A:
double sum = 0;
for (int i = 1; i <= 99; i++)
{
sum = i / (i + 1);
}
cout << "Sum is " << sum << endl;
B:
double sum = 0;
for (int i = 1; i < 99; i++)
{
sum += i / (i + 1);
}
cout << "Sum is " << sum << endl;
C:
double sum = 0;
for (int i = 1; i <= 99; i++)
{
sum += 1.0 * i / (i + 1);
}
cout << "Sum is " << sum << endl;
D:
double sum = 0;
for (int i = 1; i <= 99; i++)
{
sum += i / (i + 1.0);
}
cout << "Sum is " << sum << endl;
E:
double sum = 0;
for (int i = 1; i < 99; i++)
{
sum += i / (i + 1.0);
}
cout << "Sum is " << sum << endl;
A. BCD
B. ABCD
C. B
D. CDE
E. CD
5. Quyidagi ikkita siklda sum o`zgaruvchisi bir xil qiymat qabul qiladimi?
for (int i = 0; i < 10; ++i)
{
sum += i;
}
for (int i = 0; i < 10; i++)
{
sum += i;
}
A.ha
B. yo`q
6. Quyidagi dasturda Y qanday qiymatga ega bo`ladi?
int y = 0;
for (int i = 0; i < 10; ++i)
{
y += i;
}
A. 9
B. 10
C. 11
D. aniqlanmagan
7. Necha marta chop etish buyrug`i amalga oshirildi?
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
cout << i * j << endl;
A. 100
B. 20
C. 10
D. 45
8. . Necha marta chop etish buyrug`i amalga oshirildi?
for (int i = 0; i < 10; i++)
for (int j = 0; j < i; j++)
cout << i * j << endl;
A. 100
B. 20
C. 10
D. 45
9. Quyidagi sikl to'g'rimi?
for (; ; );
A. ha
B.yo`q
10. Quyidagi to'rtta shablonni hisobga olgan holda,
model A model B model C model D
1 1 2 3 4 5 6 1 1 2 3 4 5 6
1 2 1 2 3 4 5 2 1 1 2 3 4 5
1 2 3 1 2 3 4 3 2 1 1 2 3 4
1 2 3 4 1 2 3 4 3 2 1 1 2 3
1 2 3 4 5 1 2 5 4 3 2 1 1 2
1 2 3 4 5 6 1 6 5 4 3 2 1 1
ushbu dastur kodi yuqoridagi modellarni qaysi birini ifodalaydi?
for (int i = 1; i <= 6; i++)
{
for (int j = 6; j >= 1; j--)
if (j <= i)
cout << j << " ";
else
cout << " ";
cout << endl;
}
A.A MODEL
B.B MODEL
C. C MODEL
D. D MODEL
11. Quyidagi dastur kodini tahlil qiling.
int main()
{
int i = 0;
for (i = 0; i < 10; i++);
cout << i + 4;
return 0;
}
A.Dastur kompilyatsiyasida sikldan keyin (;) qo`yilganligi sabab xato ro`y beradi .
B. Dasturda kompilyatsiyasida xatolik for sikli e`lon qilingan satrda (;) va 4 ni ko'rsatadi
C. Dastur kompilyatsiya qilinadi for sikl tanasi so`ngida (;) va ekranga 14 natija chop etiladi.
D. Ushbu dasturda for sikli (i = 0; i <10; i ++) {}; cout << i + 4; sikl kabi vazifada bajariladi.
12. Sikl tugagandan so`ng konsol oynasiga qanday xabar chiqadi?
int number = 25;
int i;
bool isPrime = true;
for (i = 2; i < number; i++)
{
if (number % i == 0)
{
isPrime = false; break;
}
}
cout << "i is " << i << " isPrime is " << isPrime << endl;
A. i is 5 isPrime is 1
B. i is 5 isPrime is 0
C. i is 6 isPrime is 1
D. i is 6 isPrime is 0
13. Quyidagi siklda iteratsiyalar soni nechta?
for (int i = 1; i <= n; i++)
{
// iteration
}
A. 2*n
B. n
C. n - 1
D. n + 1
14. Ushbu dasturda number=9 kiritilsa qanday natija chiqadi?
#include
using namespace std;
int main()
{
cout << "Butun son kiriting: ";
int number;
cin >> number;
int i;
bool isPrime = true;
for (i = 2; i < number && isPrime; i++)
{
if (number % i == 0)
{
isPrime = false;
}
}
cout << "i bu " << i << endl;
if (isPrime)
cout << number << " tub son" << endl;
else
cout << number << " tub son emas" << endl;
return 0;
}
A. i is 3 followed by 9 is prime
B. i is 3 followed by 9 is not prime
C. i is 4 followed by 9 is prime
D. i is 4 followed by 9 is not prime
10>
|
| |