coding with ☕️
2 subscribers
262 photos
14 videos
11 files
165 links
Anwendungsentwicklung
Download Telegram
Diqqat! Ushbu kunning izlanishlarida dinamik xotiradan foydalanish taqiqlanadi.

Kvest 1. Argumentlar va ko'rsatkichlar.
> Ombordagi src jildini ko'ring

Siz bir nechta fayllarni, jumladan, maxmin modulini ko'rasiz.

> Maxmin modulini alohida yuklang

Segmentation fault
Buni tuzatishga to‘g‘ri keladi shekilli.

...

> Men butun umrim davomida maxmin modullarini tuzatishni orzu qilganman.

> Eslatmani oching

UNUTMANG! Sizning barcha dasturlaringiz uslub normasi va xotira oqishlari uchun sinovdan o'tkaziladi. Ishga tushirish ko'rsatmalarida testlar ro'yxati ham papkada materialsjoylashgan

== 1-kvest qabul qilindi. src/maxmin.c dasturida tuzatishlar kiriting, shunda u o'zini kompilyatsiya qiladi va to'g'ri ishlaydi (3 ta butun sondan maksimal va minni topadi va ularni ekranda ko'rsatadi). Dasturning tuzilishini o'zgartirmang. Agar noto'g'ri kiritilgan bo'lsa, siz n/a chiqarishingiz kerak. Tizim yadrosiga to'g'ridan-to'g'ri kirish mumkin bo'lgan system() funktsiyasi va boshqa shunga o'xshash funktsiyalardan foydalangan holda tizim qo'ng'iroqlarini amalga oshirish taqiqlanadi. Bu taqiq barcha keyingi kvestlar uchun amal qiladi ==

Kirish Chiqish
1 2 3 3 1
YUKlanmoqda…
void maxmin(int prob1, int prob2, int prob3, int *max, int *min);

/* Find a max & min from 3 numbers */
int main()
{
int x, y, z;

if (scanf("%d %d %d", &x, &y, &z) != 3) {
printf("n/a\n");
return 1;
}

int max, min;

maxmin(x, y, z, &max, &min);

printf("%d %d\n", max, min);

return 0;
}

/* Fixed maxmin function */
void maxmin(int prob1, int prob2, int prob3, int *max, int *min)
{
*max = *min = prob1;

if (prob2 > *max) *max = prob2;
if (prob2 < *min) *min = prob2;

if (prob3 > *max) *max = prob3;
if (prob3 < *min) *min = prob3;
}
int main() {
int time = 22;
if (time < 10) {
printf("Good morning.");
} else if (time < 20) {
printf("Good day.");
} else {
printf("Good evening.");
}
return 0;
}
IF / ELSE statement
int main() {
int doorCode = 1337;

if (doorCode == 1337) {
printf("Correct code.\nThe door is now open.");
} else {
printf("Wrong code.\nThe door remains closed.");
}

return 0;
}
if (myNum > 0) {    printf("The value is a positive number.");
}

Agar myNum 0 dan katta bo‘lsa (10 > 0 → ha), ekranga "The value is a positive number." yoziladi.
}

gar myNum 0 dan kichik bo‘lsa (bu holda noto‘g‘ri, chunki 10 > 0), bu qism bajarilmaydi.
int main() {
int myAge = 25;
int votingAge = 18;

if (myAge >= votingAge) {
printf("Old enough to vote!");
} else {
printf("Not old enough to vote.");
}

return 0;
}
git push origin develop
exam-tash.21-school.ru
ssh-keygen
keygen
Node.js + Express.js CRUD API – Todo App Documentation


---

🧱 Project Goal:

Create a simple Todo API using Express.js to understand CRUD operations with in-memory data.


---

📁 File Structure:

project/
├── index.js # Main Express server
└── data.js # Todo list in-memory data


---

📄 data.js

let todos = [
{ id: 1, text: 'Learn Node.js' },
{ id: 2, text: 'Build an API' }
];

module.exports = todos;


---

📄 index.js

const express = require('express');
const app = express();
const PORT = 3000;

let todos = require('./data');

app.use(express.json());

// GET all todos
app.get('/todos', (req, res) => {
res.json(todos);
});

// GET a single todo
app.get('/todos/:id', (req, res) => {
const id = parseInt(req.params.id);
const todo = todos.find(t => t.id === id);
if (todo) res.json(todo);
else res.status(404).json({ error: 'Todo not found' });
});

// POST a new todo
app.post('/todos', (req, res) => {
const { text } = req.body;
const newTodo = { id: Date.now(), text };
todos.push(newTodo);
res.status(201).json(newTodo);
});

// PUT to update a todo
app.put('/todos/:id', (req, res) => {
const id = parseInt(req.params.id);
const { text } = req.body;
const todo = todos.find(t => t.id === id);
if (todo) {
todo.text = text;
res.json(todo);
} else res.status(404).json({ error: 'Todo not found' });
});

// DELETE a todo
app.delete('/todos/:id', (req, res) => {
const id = parseInt(req.params.id);
todos = todos.filter(t => t.id !== id);
res.status(204).end();
});

app.listen(PORT, () => console.log(Server running on http://localhost:${PORT}));


---

🧪 Testing the API (Use Postman or Thunder Client)

Method URL Body Example

GET /todos -
GET /todos/1 -
POST /todos { "text": "Practice Express" }
PUT /todos/1 { "text": "Updated Todo" }
DELETE /todos/1 -



---

Next Steps:

Step 3: Middleware & Routing

Step 4: MongoDB integration

Step 5: Authentication with JWT


Keep practicing and building small projects to master backend logic! 🚀
Albatta, C dasturlash tilidagi massivlar (arrays) mavzusini senga imtongacha tez va to‘liq tushuntirib beraman. Bu tushuncha testda ham, kod yozishda ham kerak bo‘ladi. Boshladik:


---

1. Massiv nima?

Massiv (array) — bu bir xil turdagi bir nechta elementlarni bitta nom ostida saqlaydigan ma’lumotlar to‘plami.


---

2. Massiv qanday e'lon qilinadi?

tip_nomi nomi[miqdori];

Misol:

int sonlar[5]; // 5 ta butun son saqlaydi


---

3. Massivga qiymat berish

a) Bosqichma-bosqich:

s```onlar[0] = 10;
sonlar[1] = 20;


b) To‘liq boshlash:

```int sonlar[5] = {10, 20, 30, 40, 50};



---

4. Massiv elementiga murojaat qilish

printf("%d", sonlar[2]);  // 30 ni chiqaradi

> Eslatma: C tilida indekslash 0 dan boshlanadi. Ya’ni sonlar[0] — birinchi element.





---

5. For sikli bilan massivni o‘qish
for (int i = 0; i < 5; i++) {
printf("%d ", sonlar[i]);
}


---

6. Foydalanuvchidan massivga qiymat kiritish

int a[5];
for (int i = 0; i < 5; i++) {
scanf("%d", &a[i]);
}



---

7. Belgilar (char) massivi — string

char ism[10] = "Ali";
printf("%s", ism); // Natija: Ali

> Belgilar massivi satrni ifodalaydi. U \0 bilan tugaydi.




---

8. Massiv o‘lchami — sizeof

int sonlar[5];
int uzunlik = sizeof(sonlar) / sizeof(sonlar[0]);



---

9. 2 o‘lchovli massiv (matritsa)

int m[2][3] = {
{1, 2, 3},
{4, 5, 6}
};
printf("%d", m[1][2]); // 6



---

10. Massivni funktsiyaga uzatish

void chiqar(int a[], int n) {
for (int i = 0; i < n; i++)
printf("%d ", a[i]);
}



---

📌 Muhim savollar uchun tayyor bo‘l:

1. Massivdagi birinchi elementga qanday murojaat qilinadi? → a[0]


2. Massivdagi oxirgi element? → a[n-1]


3. Indeks tashqarisiga chiqilsa? → Undefined behavior (xatolik!)


4. String nima? → Belgilar massivi (char[])


5. C tilida massiv uzunligi o‘zgaradimi? → Yo‘q, statik (oldindan belgilanadi)




---

Agar xohlasang, test savollariga o‘xshatib 5–10 ta mini imtihon tuzib ham beraman. Shunchaki ayt 😊
Omad bo‘lsin! 🙌
#include <stdio.h>
#include <string.h>

// So'zni teskari qilish funksiyasi
void reverse(char *str) {
int left = 0;
int right = strlen(str) - 1;
while (left < right) {
// Belgilarni almashtirish
char temp = str[left];
str[left] = str[right];
str[right] = temp;
left++;
right--;
}
}

int main() {
char word[100];

printf("So'z kiriting: ");
scanf("%99s", word); // Faqat bitta so'z (bo'shliqgacha)

reverse(word);

printf("Teskari: %s\n", word);
return 0;
}
printf("Teskari: ");
for (int i = length - 1; i >= 0; i--) {
printf("%c", word[i]);
}
printf("\n");

return 0;
}
JavaScript Fundamentals

Before starting with Node.js, you should be familiar with these JavaScript concepts:

Variables
Functions
Objects
Arrays
Asynchronous programming (callbacks, promises, async/await)
ES6+ features
JavaScript Fundamentals

Before starting with Node.js, you should be familiar with these JavaScript concepts:

Variables
Functions
Objects
Arrays
Asynchronous programming (callbacks, promises, async/await)
ES6+ features