coding with ☕️
2 subscribers
262 photos
14 videos
11 files
165 links
Anwendungsentwicklung
Download Telegram
int main() {
int day = 4;

switch (day) {
case 1:
printf("Monday");
break;
case 2:
printf("Tuesday");
break;
case 3:
printf("Wednesday");
break;
case 4:
printf("Thursday");
break;
case 5:
printf("Friday");
break;
case 6:
printf("Saturday");
break;
case 7:
printf("Sunday");
break;
}

return 0;
}
int main() {
int day = 4;

switch (day) {
case 6:
printf("Today is Saturday");
break;
case 7:
printf("Today is Sunday");
break;
default:
printf("Looking forward to the Weekend");
}

return 0;
}
`Shartlar va agar bayonotlar
Siz allaqachon C matematikadan odatiy mantiqiy shartlarni qo'llab-quvvatlashini bilib oldingiz:

Kichikroq: a < b
Kichik yoki teng: a <= b
Kattaroq: a > b
dan katta yoki teng: a >= b
a == b ga teng
Teng emas: a != b
Turli qarorlar uchun turli harakatlarni bajarish uchun ushbu shartlardan foydalanishingiz mumkin.

C quyidagi shartli bayonotlarga ega:

ifAgar belgilangan shart bo'lsa, bajarilishi kerak bo'lgan kod blokini belgilash uchun foydalaningtrue
elseAgar bir xil shart bo'lsa, bajariladigan kod blokini belgilash uchun foydalaningfalse
else ifSinov uchun yangi shartni belgilash uchun foydalaning , agar birinchi shart bo'lsafalse
switchBajariladigan ko'plab muqobil kod bloklarini belgilash uchun foydalaning`
VARIABLES
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! 🚀