Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

C Program for Matrix Addition using Arrays and Functions

Classified in Computers

Written on in English with a size of 3.8 KB

This document presents two methods for implementing matrix addition in C: a monolithic approach within the main function and a modular approach utilizing separate functions for input, calculation, and display. Both examples handle 2D arrays up to 100x100 dimensions.

Method 1: Monolithic Implementation in main()

This initial approach places all logic—input handling, calculation, and output—directly within the main function. The code below has been corrected for proper C syntax, including loop conditions and scanf format specifiers.

Corrected C Code Snippet 1

#include <stdio.h>
#include <stdlib.h>

void main(void) {
    float a[100][100], b[100][100], c[100][100];
    int rows, columns, i, j;

    printf("Enter number of rows: ");
... Continue reading "C Program for Matrix Addition using Arrays and Functions" »

MySQL Database Management: Users, Permissions, Tables

Classified in Computers

Written on in English with a size of 3.76 KB

Users

  • Creation

From the Partner's Computer

  • Create user `Professor` @ '192.168.5.25' identified by 'Professor';

Local Access

  • Administrative user `Create` @ 'localhost' identified by 'Administrative';

Access from Any Computer

  • Create user `` @ '%' student identified by 'student';
  • Deletion

  • DROP
  • Permissions

To Grant Permissions

  • GRANT SELECT ON clase.cuidadores TO 'student'@'localhost';
SELECT * FROM carers;
  • GRANT SELECT (name, currency) ON clase.cuidadores TO 'student'@'localhost';
SELECT name FROM currency carers;
  • GRANT INSERT, SELECT, UPDATE ON IES.Curso TO 'Administrative'@'localhost';
  • GRANT INSERT (IdCurso, DNI), SELECT (IdCurso, DNI), UPDATE (IdCurso, ID) ON IES.Matrícula TO 'Administrative'@'localhost';

With Update

  • GRANT SELECT (name, currency), UPDATE (currency)
... Continue reading "MySQL Database Management: Users, Permissions, Tables" »

Dining Philosophers Problem: C Implementation with Pthreads

Classified in Computers

Written on in English with a size of 2.22 KB

C Implementation of the Dining Philosophers Problem

This program simulates the Dining Philosophers problem using C and Pthreads to demonstrate concurrency and synchronization concepts.

Global Variables

  • num_filosofos (int): Number of philosophers.
  • seed (int): Seed for random number generation.
  • holders (pthread_mutex_t*): Array of mutexes representing forks.
  • timeIni (long): Initial time in milliseconds.

Functions

long dameTiempo()

Returns the current time in milliseconds.

int eat(int n)

Simulates a philosopher eating.

  • TimeWait (long): Random wait time (0-500 ms).
  • Prints a message indicating the philosopher is eating.
  • Waits for TimeWait milliseconds.
  • Releases the left and right forks (mutexes).

int sleep(int n)

Simulates a philosopher sleeping.

  • TimeWait (long):
... Continue reading "Dining Philosophers Problem: C Implementation with Pthreads" »

ADSL and DSL Technologies: A Comprehensive Overview

Classified in Computers

Written on in English with a size of 2.4 KB

ADSL and DSL Technologies

ADSL (Asymmetric Digital Subscriber Line)

Advantages

  • User: High-speed access, permanent connection, fast service provisioning.
  • Telephone Company: Dual function of existing cable, no central office occupation, no risk of switched network collapse, service installed only on requested lines.

Disadvantages

  • Service unavailability on certain lines (poor condition, distance from the central office).
  • Potential for poor quality home cabling.
  • Router cost.
  • Requires a phone line.
  • Cost in Spain.
  • Theoretical limit for acceptable service at 5.5 km line length.

ADSL2+

Extends ADSL downstream capability with bit folding, achieving speeds of up to 24 Mbps downstream and 3.5 Mbps upstream. Doubles bandwidth from 1.1 MHz to 2.2 MHz.

ATM over ADSL

Allows... Continue reading "ADSL and DSL Technologies: A Comprehensive Overview" »

Essential Excel Features and Pascal Programming Concepts

Classified in Computers

Written on in English with a size of 4.6 KB

Excel Fundamentals

1. Decrease Indent

Reduces the indentation level of content within a cell.

2. Increase Indent

Increases the indentation level of content within a cell.

Also related: Increase Margin.

3. Orientation

Adjusts the direction of text or objects.

  • Vertical Orientation: Arranges text or objects vertically.

4. Insert Menu Contents

The Insert Menu typically contains options to add various elements to your worksheet:

  • Cells
  • Chart Sheet
  • Symbol
  • Page Break
  • Function
  • Name
  • Comment
  • Image
  • Diagram
  • Object
  • Hyperlink

5. Format Menu Contents

The Format Menu provides options for styling and arranging elements:

  • Cells
  • Rows
  • Columns
  • Sheet
  • Format (e.g., AutoFormat)
  • Conditional Formatting
  • Style

6. Tools Menu Contents

The Tools Menu offers utilities for various tasks:

  • Spelling
  • Reference (
... Continue reading "Essential Excel Features and Pascal Programming Concepts" »

Understanding Relational Database Models: Concepts and Operations

Classified in Computers

Written on in English with a size of 3.26 KB

Relational Model: An In-Depth Look

The relational model allows users to obtain information from the database without needing assistance from information management professionals. The data is stored in a way that:

  • Users understand it more easily.
  • The data is stored as tables.
  • Relationships between rows and tables are visible within the data.

Features of Relational Models

  • It is important to know that the entries in the table are atomic.
  • All entries in any column are of a single type. The table columns are called attributes.
  • No two rows in the table are identical.

Structure of Relational Databases

At the conceptual level, the relational database model is represented by a collection of stored relations.

Submodel Data

External schemas of relational sub-models... Continue reading "Understanding Relational Database Models: Concepts and Operations" »

Core Network Communication Protocols and Distributed Systems Explained

Classified in Computers

Written on in English with a size of 3.78 KB

Understanding Network Communication Models

Client-Server Communication Model

In the Client-Server model, one process (the server) executes orders or commands requested by another process (the client).

Distributed Applications

Distributed applications consist of different programs that may be located on various machines, such as client and server machines, working together to achieve a common goal.

Network Communication Layers

Network communication can be conceptualized at different levels:

  • Application Layer: Deals with the communication processes of application components.
  • Physical/Architectural Layer: Focuses on the physical transmission of information.

Protocols and Services

  • Protocol: A set of rules governing communication between two entities at a
... Continue reading "Core Network Communication Protocols and Distributed Systems Explained" »

Java Student Class: Attributes, Methods, and Status

Classified in Computers

Written on in English with a size of 3.34 KB

This document presents a Java class named Student, demonstrating object-oriented programming principles. It includes attributes, constructors, getters, setters, and methods to calculate average grades and determine student status.

Test Class

import java.io.*;
public class Test {
    public static void main(String[] args) throws IOException {
        Student student = new Student("John", true, 3, 2, 5, 43);
        student.show();
    }
}

Student Class

import java.io.*;
public class Student {
    private int note1, note2, note3;
    private String name;
    private int age;
    private boolean sex; // attributes

    public Student() {
        this.name = "NN";
        this.sex = false;
        this.note1 = 0;
        this.note2 = 0;
        this.
... Continue reading "Java Student Class: Attributes, Methods, and Status" »

C++ Staff Management: Inheritance and Polymorphism

Classified in Computers

Written on in English with a size of 10.44 KB

C++ Staff Management System: Inheritance and Polymorphism

This document presents a refactored C++ program demonstrating object-oriented principles such as inheritance and polymorphism. The system models a basic staff management application, featuring a base Officer class and derived classes for specific roles like JusticeOfficer and Firefighter. It highlights dynamic memory management, virtual functions, and runtime polymorphism.

Core Concepts Illustrated

  • Inheritance: JusticeOfficer and Firefighter inherit from the base Officer class.
  • Polymorphism: Virtual functions (insert(), show(), destructor) allow for different behaviors based on the actual object type at runtime.
  • Dynamic Memory: Usage of new and delete[] for character arrays (DNI, names) and
... Continue reading "C++ Staff Management: Inheritance and Polymorphism" »

Pascal Complex Number Arithmetic Program

Classified in Computers

Written on in English with a size of 2.49 KB

NosComp Program;

uses crt;

Type
Record number =
Real: Real;
imag: Real;
End;

Var
n1, n2: number;
resp: char;

Procedure LeerDatos;
begin
writeln ('Real part of the first number');
readln (n1.real);
writeln ('Imaginary part of the first number');
readln (n1.imag);
writeln ('Real part of the second number');
readln (n2.real);
writeln ('Imaginary part of the second number');
readln (n2.imag);
end;

Procedure Sum;
Begin
write ('The result of adding them is:');
if (n1.imag + n2.imag) >= 0 then
writeln ( (n1.real + n2.real):2:2, '+', (n1.imag + n2.imag):2:2, 'i')
else
writeln ( (n1.real + n2.real):2:2, '-', abs (n1.imag + n2.imag):2:2, 'i')
end;

Procedure Subtraction;
begin
write ('The result of subtracting them is:');
if (n1.imag... Continue reading "Pascal Complex Number Arithmetic Program" »