Notes, summaries, assignments, exams, and exercises for Computer science for Primary education
UrarenKalitatea: Pascal Source Code for Water Quality
UrarenKalitatea Pascal Source Code
The following is a complete Pascal program designed to manage and calculate water quality measurements and indices.
PROGRAM UrarenKalitatea ;
USES
Crt, SysUtils ;
CONST
MAX_NEURKETAK = 1000 ;
TYPE
tsKateLabur = STRING [10] ;
tsKateLuze = STRING [150] ;
tarOinarrizkoParametroak = ARRAY [1..9] OF Real ;
trdNeurketa = RECORD
sBehatokia,
sData: tsKateLabur ;
rKIO: Real ;
iKI: Integer ;
arParametroak : tarOinarrizkoParametroak ;
END ;
tardNeurketenZerrenda = ARRAY [1..MAX_NEURKETAK] OF trdNeurketa ;
tfrdNeurketenFitxategia = FILE OF trdNeurketa ;
FUNCTION fncAukeraIrakurri : Char ;
VAR
cAukera : Char ;
BEGIN
Writeln('1. Neurketen fitxategiaren edukia erakutsi') ;
Writeln(...Key C++ Programming Principles and Comparisons
1) What is C++? Advantages of C++
C++ is an object-oriented programming language developed by Bjarne Stroustrup. It is an extension of the C language.
Advantages:
- Supports Object-Oriented Programming.
- Code reuse using inheritance.
- Fast execution.
- Data security through encapsulation.
- Portable language.
- Supports function and operator overloading.
2) Difference Between Procedural and Object-Oriented Programming
| Procedural Programming | Object-Oriented Programming |
|---|---|
| Program divided into functions | Program divided into objects |
| Top-down approach | Bottom-up approach |
| Less data security | More data security |
| Example: C | Example: C++ |
3) Six Advantages of OOP
- Data hiding provides security.
- Code reusability using inheritance.
- Easy program maintenance.
- Reduces program complexity.
- Easy debugging.
Backup, Cryptography and GnuPG: A Practical Security Reference
Backup
Important directories: /etc, /home, /var, /usr, /local
Package and compress with tar. Files: home.tar
# tar -cvf home.tar /home
Compression:
# gzip -r /home/* (recursive compression)
Decompression:
# gunzip -r /home/* (recursive decompression)
Cryptography
In cryptography, digital signatures are a digital information authentication method, known as signature.
The art of cryptanalysis is the study of attempts to break ciphertext.
Key + algorithm + message = ciphertext
CID + Authentication + Irretrievability
Encryption: C = Ek(M). Decryption: M = Dk(C)
Steganography: secret communication by hiding the existence of the message.
Steganalysis: detection of steganographic content.
Examples of cryptographic protocols: SSL, SSH, IPSec, WEP, WPA
Symmetric algorithms:...
Key Concepts in IT: Client Facilities, XML, and Security
Client Facilities
Client Facilities: Performance, ensure integrity, updates, risk confidential. Static pages, forms, active content, plugins, stand-alone applications.
XML
XML (Extensible Markup Language): Preferred form for B2B and internal documents with legal effect. Key benefits: non-proprietary, platform independent, HTTP compatibility, international support, extensible, self-defining, common tools, and transformation. Complementary techniques: UDDI (Universal Description, Discovery, and Integration), WSDL (Web Services Description Language) – web service design. Signatures have legal effect.
Components
Components: Good because turn-key systems tend to be too large and inflexible. Advantages: higher quality and design, maintenance shared,...
Java MySQL CRUD Operations Code Snippets
Conexão
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root", "abc123");
} catch (ClassNotFoundException dri) {
System.out.println("Erro ao carregar o driver" + dri.getMessage());
} catch (SQLException sql) {
System.out.println("Erro ao conectar ao banco de dados" + sql.getMessage());
} catch (Exception e) {
throw new RuntimeException(e);
}Insert
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root", "abc123");
String sql = "insert into dados.Pessoa (nome, idade, sexo) values (?, ?, ?)";
try {
PreparedStatement stmt = con.prepareStatement(sql);
Pessoa p = (Pessoa) o;
stmt.setString(1, p.getNome());
stmt.C File Handling Techniques: Data Storage and Retrieval Examples
C Example 1: Writing Structured Data to a File
This program demonstrates appending structured date data (assuming struct fecha is defined elsewhere) to a file named Dades.txt. It includes basic file opening and error checking.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int temp = 1;
int auxiliar = 0;
int i = 0;
FILE *v1;
v1 = fopen("Dades.txt", "a");
// Note: Variables 'origen' and 'destino' are undefined in this snippet.
if (origen == NULL || destino == NULL) {
printf("Problemas con los ficheros.\n");
exit(1);
}
printf("Inserte el día, mes y año. El programa finalizará marcando 0 en el día:\n\n");
while (temp != 0) {
printf("Día:\...Essential C++ Programming Examples and Database Concepts
1. C++ Pointer Declaration and Initialization
Ans:
#include <iostream>
using namespace std;
int main() {
int num = 10;
int *ptr = #
cout << "Value of num: " << num << endl;
cout << "Address of num: " << &num << endl;
cout << "Pointer ptr stores: " << ptr << endl;
cout << "Value pointed by ptr: " << *ptr << endl;
return 0;
}2. C++ Program to Add Two 4x4 Matrices
Ans:
#include <iostream>
using namespace std;
int main() {
int A[4][4], B[4][4], C[4][4];
cout << "Enter elements of first 4x4 matrix:\n";
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
cin >> A[i][j];...Ec lab
Postfix evaluation
#include<stdio.H>
int stack[20];
int top = -1;
void push(int x)
{
stack[++top] = x;
}
int pop()
{
return stack[top--];
}
int main()
{
char exp[20];
char *e;
int n1,n2,n3,num;
printf("Enter the expression :: ");
scanf("%s",exp);
e = exp;
while(*e != '\0')
{
if(isdigit(*e))
{
num = *e - 48;
push(num);
}
else
{
n1 = pop();
n2 = pop();
switch(*e)
{
case '+':
{
n3 = n1 + n2;
break;
}
case '-':
{
...
It used to define the member functions of a class outside
-Measure & Metric & Indicator
not provide enough information
comparison of two or more measures
Compares a metric against a baseline
-To improve a process
Measure specific attributes
of process
Develop meaningful metrics
metrics provide indicators
Example Metrics derived:
Errors before software release,
defects delivered to &
reported by end-user
work products delivered
Human efforts expended
Calendar time expended
-Improving Software Quality
& Organizational Performance
people.Product,technology
-Software measurement
Direct Measures:Cost and effort
Line of Code & Execution Speed
Indirect Measures
Functionality,Quality
Complexity,Efficiency
Reliability,Maintainability
-1som:Derived by normalizing quality
LOC,cost,errors,defects
Effort...