№5. Ichma ich joylashgan If shartli operatori. Switch tanlash operatori.
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) AB D) BC
3. Quyidagi siklda ekranga _______________ chiqadi.
for (int i = 1; i <= 10; i++)
{ cout << i << " ";
i++; }
A)1 2 3 4 5 6 7 8 9 B) 1 2 3 4 5 6 7 8 9 10
C)1 2 3 4 5 D)1 3 5 7 9
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) CD B) ABCD C) B D) CDE
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 qismni tahlil qiling:
10>
Do'stlaringiz bilan baham: |