Dastur kodi void main { int n = 1000; int prod = 1; for (int I = 0; I < n; i++) { if (I 10 5) { prod *= I; } } print(prod); } Dastur natijasi


Download 264.83 Kb.
Sana27.10.2023
Hajmi264.83 Kb.
#1726080
Bog'liq
3-laboratoriya


3-laboratoriya ishi.
Narzullayev Saidakbar

  1. 1000 gacha bulgan sonlarni ichida faqat oxiri 5 bilan tugagan sonlarni kupaytmasini hisoblaydigan formulani toping

Dastur kodi.
void main() {
int n = 1000;
int prod = 1;
for (int i = 0; i < n; i++) {
if (i % 10 == 5) {
prod *= i;
}
}
print(prod);
}


Dastur natijasi:


  1. Birdan mingacha bólgan 3 honali va 2 honali sonlardan faqat juftlarini chiqaradigan logika tuzing.

Dastur kodi

void main() {


for (int i = 0; i < 1000; i++) {
if (i > 9 && i < 1000 && i % 2 == 0) {
print(i);
}
}
}
Dastur natijasi




  1. Berilgan sonni nechi xonadan iborat ekanligini sanab beruvchi logika tuzing.

Dastur kodi
import 'dart:io';

main() {
print("Sonni kiriting: ");


int son = int.parse(stdin.readLineSync()!);
int xonalar_soni = 0;

while (son > 0) {


son = son ~/ 10;
xonalar_soni++;
}

print("Ushbu son $xonalar_soni xonali son");


}
Dastur natijasi




  1. factorialni hisoblaydigan dastur tuzing.

Dastur kodi
import 'dart:io';

void main() {


print("Son kiriting: ");
int n = int.parse(stdin.readLineSync()!);
int factorial = 1;
for (int i = 1; i <= n; i++) {
factorial *= i;
}
print("$n! = $factorial");
}
Dastur natijasi




  1. Berilgan son Palindrom yoki Palindrom emasligini aniqlovchi logika tuzing

Dastur kodi
import 'dart:io';

void main() {


print("Son kiriting: ");
int son = int.parse(stdin.readLineSync()!);

int a = son;


int m = 0;
while (a > 0) {
m = m * 10 + a % 10;
a = a ~/ 10;
}
if (m == son) {
print("Palindrom");
} else {
print("Palindrom emas");
}
}


Dastur natijasi



Download 264.83 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling