Notes, summaries, assignments, exams, and exercises for Computer science for Primary education

Implementing 3D Vector Operations in C Programming

Computer science4.19 KB

C Program for 3D Vector Algebra Implementation

This C program demonstrates the implementation of fundamental 3D vector operations, including addition, subtraction, scalar (dot) product, vector (cross) product, modulus calculation, and element swapping. It also includes functions for displaying vectors to the console and writing them to a file.

Header Files and Function Prototypes

#include <stdio.h>
#include <math.h>

void suma_resta(double [], double [], double [], char);
void vectorial(double [], double [], double []);
void swap(double []);
void pant_vector(double []);
void fich_vector(double []);

double escalar(double [], double []);
double modulo(double []);

Main Function Execution

The main function initializes two vectors, a and...

Continue reading "Implementing 3D Vector Operations in C Programming" »

Combinational and Sequential Logic Circuits Explained

Computer science2.22 KB

Combinational Logic Circuits

Combinational logic is a type of digital logic implemented by Boolean circuits where the output is a pure function of present inputs only. These circuits are built to implement fixed digital logic and can be used to store a fixed set of instructions (ROM) or programmed to implement specific logic (PLD and PLA circuits).

Sequential Logic Circuits

Sequential logic differs in that the output depends not only on the present input but also on the history of all previous inputs, as these circuits possess memory.

Key Components

  • Clock: A signal added to indicate when to read instructions or fetch data to the combinational circuit.
  • Operations: Combining computing tasks with management to control when operations occur and how to
...
Continue reading "Combinational and Sequential Logic Circuits Explained" »

Экзаменационные билеты по SQL и базам данных

Computer science7.34 KB

Билет 1

Теория

  1. Структурированные данные — таблицы, столбцы, связи
  2. Целостность данных — PRIMARY KEY, NOT NULL

Практика

CREATE TABLE books (
  book_id INT PRIMARY KEY,
  title VARCHAR(100) NOT NULL
);

Билет 2

Теория

  1. Реляционная модель — связи между таблицами
  2. Внешние ключи — FOREIGN KEY

Практика

CREATE TABLE authors (
  author_id INT PRIMARY KEY,
  name VARCHAR(50)
);

ALTER TABLE books ADD author_id INT REFERENCES authors(author_id);

Билет 3

Теория

  1. Нормализация — устранение дублирования
  2. Первая нормальная форма (1NF)

Практика

CREATE TABLE
...
Continue reading "Экзаменационные билеты по SQL и базам данных" »

C# WPF Login Window: Authentication with DatabaseService Example

Computer science1.62 KB

using System.Data;
using System.Windows;

namespace WpfApp1
{
public partial class LoginWindow : Window
{
private readonly DatabaseService db = new DatabaseService();

public LoginWindow()
{
InitializeComponent();
}

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
string login = LoginTextBox.Text.Trim();
string password = PasswordBox.Password.Trim();

if (login == "" || password == "")
{
MessageBox.Show("Введите логин и пароль.", "Ошибка");
return;
}

DataTable user = db.Login(login, password);

if (user.Rows.Count == 0)
{
...

Continue reading "C# WPF Login Window: Authentication with DatabaseService Example" »

Understanding Operating Systems, Software, and Computer Hardware

Computer science2.97 KB

Operating System Scheduling

1. The OS enables running multiple programs simultaneously. Several programs can reside in RAM concurrently, yet the CPU processes only one at a time. Only one process can be active at any given moment. CPUs are incredibly fast; even brief processing periods yield significant results. The OS determines the optimal method for switching between running, runnable, and waiting processes. It manages which process the CPU executes and distributes CPU access among processes. The task of determining when to switch processes is termed scheduling.

Disk Defragmentation

2. A disk defragmenter reorganizes files on a disk, ensuring they are stored contiguously. It arranges files on the disk into adjacent locations. This enhances...

Continue reading "Understanding Operating Systems, Software, and Computer Hardware" »

Responsibilities of the Transport Layer

Computer science1.9 KB

Transport Layer Responsibilities

Tracking Individual Conversations

At the transport layer, each set of data flowing between a source application and a destination application is known as a conversation (Figure 1). A host may have multiple applications that are communicating across the network simultaneously. Each of these applications communicates with one or more applications on one or more remote hosts. It is the responsibility of the transport layer to maintain and track these multiple conversations.

Segmenting Data and Reassembling Segments

Data must be prepared to be sent across the media in manageable pieces. Most networks have a limitation on the amount of data that can be included in a single packet. Transport layer protocols have services...

Continue reading "Responsibilities of the Transport Layer" »

Mastering Python Functions: Arguments, Scope, and Returns

Computer science2.65 KB

Keyword Arguments

Arguments are passed using parameter names, meaning the order does not matter.

Example

def func(name, age):
    return f"Hello {name}, you are {age} years old!"

result = func(age=18, name="John")
print(result)

Output: Hello John, you are 18 years old!


Default Arguments

Default values are assigned to parameters directly in the function definition.

Example

def func(name, greeting="Hello"):
    return f"{greeting}, {name}"

print(func("John"))
print(func("Nik", "Hi"))

Output:
Hello, John
Hi, Nik


Arbitrary Arguments

Used when the number of arguments passed to a function is unknown.

*args – Non-keyword variable length arguments

def sum_numbers(*args):
    return sum(args)

print(sum_numbers(1, 5, 10, 15))

Output: 31


**kwargs – Keyword variable

...
Continue reading "Mastering Python Functions: Arguments, Scope, and Returns" »

Python Fundamentals: Variables, Data Types, and Control Flow

Computer science14.36 KB

Keywords and identifiers are fundamental elements in programming languages used to define variables, functions, and other constructs, with keywords being reserved words that have special meanings, and identifiers being names given to user-defined entities.

Comments in programming serve the essential purpose of making the source code more understandable and maintainable by providing textual annotations that explain the logic, purpose, or any additional information about the code. They help programmers and collaborators to read, debug, and update the code efficiently without affecting its execution.

There are two main types of comments:
- Single-line comments start with specific symbols like // in languages such as C, Java, and JavaScript, and they...

Continue reading "Python Fundamentals: Variables, Data Types, and Control Flow" »

Understanding Networking: Cables, Protocols, and Topologies

Computer science3.27 KB

NETWORKING

1- Characteristics of Electronic Cables

Impedance, attenuation, and capacitance are crucial in electronic cables.

Impedance:

Resistance to electron movement in an AC circuit, measured in ohms (Ω).

Attenuation:

Resistance to electron flow, measured in db/m.

Capacitance:

Energy storage in a cable, measured in picofarads (pF).

2- Physical Description of Cables

Twisted Pair: Protects against crosstalk and noise.

Coaxial Cable: Consists of copper conductor, plastic insulation, and shielding.

Fiber-Optic Cable: Core, cladding, buffer, strengthening material, and outer jacket.

3- UTP vs. STP

Shielding reduces electrical noise in STP but makes installation complex.

4- Crimping RJ-45 UTP Cables

Creates straight-through and crossover cables for connecting...

Continue reading "Understanding Networking: Cables, Protocols, and Topologies" »