0% found this document useful (0 votes)
13 views5 pages

Mustaqil Ish

The document is a programming assignment from the Tashkent University of Information Technologies focusing on various programming concepts. It includes examples of code for prime number generation, multi-dimensional arrays, file handling, and structures in C++. Each section provides code snippets along with expected results.

Uploaded by

nurbekdeveloper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Mustaqil Ish

The document is a programming assignment from the Tashkent University of Information Technologies focusing on various programming concepts. It includes examples of code for prime number generation, multi-dimensional arrays, file handling, and structures in C++. Each section provides code snippets along with expected results.

Uploaded by

nurbekdeveloper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

O’ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR

VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT
TEXNOLOGIYALARI UNIVERSITETI

DASTURLASH FANIDAN

MUSTAQIL ISH

Bajardi: Ergashaliyev A
Tekshirdi: Qodirov Z

TOSHKENT-2025
5-variant.

1. Takrorlanuvchi operatorlar.
KOD:
#include <iostream>
using namespace std;

int main() {
cout << "1 dan 100 gacha bo'lgan tub sonlar:\n";
for (int i = 2; i <= 100; i++) {
bool tub = true;
for (int j = 2; j * j <= i; j++) {
if (i % j == 0) {
tub = false;
break;
}
}
if (tub) {
cout << i << endl;
}
}
cout << endl;
return 0;
}

NATIJA:
2. Ko’p o’lchovli massiv
KOD:
#include <iostream>
using namespace std;

int main() {
int mat[3][3] = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};

cout << "Transponirlangan matritsa:\n";


for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cout << mat[j][i] << " ";
}
cout << endl;
}
return 0;
}

NATIJA:

3. Matnli fayllar bilan ishlash


KOD:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main() {
ifstream fayl("matn.txt");
if (!fayl) {
cout << "Fayl topilmadi!" << endl;
return 1;
}

string satr;
while (getline(fayl, satr)) {
cout << satr << endl;
}

fayl.close();
return 0;
}
NATIJA:

4. Struktura yaratish va obyektlar ustida amallar bajarish.


KOD:
#include <iostream>
using namespace std;
struct Ishchi {
string ism;
int ish_haqi;
};
int main() {
const int N = 3;
Ishchi ishchilar[N];
for (int i = 0; i < N; i++) {
cout << i+1 << "-ishchi ismi: ";
cin >> ishchilar[i].ism;
cout << i+1 << "-ishchi ish haqi: ";
cin >> ishchilar[i].ish_haqi;
}
int eng_katta = 0;
for (int i = 1; i < N; i++) {
if (ishchilar[i].ish_haqi > ishchilar[eng_katta].ish_haqi) {
eng_katta = i;
}
}
cout << "\nEng ko'p ish haqi olgan ishchi: " << ishchilar[eng_katta].ism
<< " - $" << ishchilar[eng_katta].ish_haqi << endl;

return 0;
}

NATIJA:

You might also like