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

Sort by
Subject
Level

C Programming Basics: Examples and Explanations

Classified in Computers

Written on in English with a size of 2.72 KB

C Programming Basics

Printing a Message

int main() { print("Hello!!!"); }

Variables and Mathematical Calculations

int main() // Main function

{

int a = 25; // Initialize a variable to 25

int b = 17; // Initialize b variable to 17

int c = a + b; // Initialize c variable to a + b

print("c = %d ", c); // Display decimal value of c

}

Floating-Point Math

int main() // Main function

{

float r = 1.0; // Set radius to 1.0

float c = 2.0 * PI * r; // Calculate circumference

print("circumference = %f \n", c); // Display circumference

}

Arrays

int main() // Main function

{

int p[] = {1, 2, 3, 5, 7, 11}; // Initialize the array

print("p[0] = %d\n", p[0]); // Display what p[0] stores

print("p[3] = %d\n", p[3]); // Display what p[3] stores

p[3] = 101; // Assignment

}

... Continue reading "C Programming Basics: Examples and Explanations" »

Understanding Key Computer Science Concepts

Posted by Lijia and classified in Computers

Written on in English with a size of 3.47 KB

Fetch-Execute Cycle

  1. The address in the program counter is transferred within the CPU to the Memory Address Register (MAR).
  2. During the next clock cycle, two things happen simultaneously:
    • The instruction held in the address pointed to by the MAR is fetched into the Memory Data Register (MDR).
    • The address stored in the program counter is incremented.
  3. The instruction stored in the MDR is transferred within the CPU to the Current Instruction Register (CIR).

Sound Sampling

  1. The amplitude of the sound wave is determined to get an approximation of the sound wave.
  2. This is encoded as a sequence of binary numbers and converted to a digital signal.
  3. Increasing the sampling rate will improve the accuracy of the recording.

Run-Length Encoding (RLE)

  1. RLE is a lossless
... Continue reading "Understanding Key Computer Science Concepts" »

Understanding Computer Architecture: Key Components and Functions

Classified in Computers

Written on in English with a size of 2.95 KB

List and Briefly Define the Four Main Elements of a Computer

A computer is composed of four fundamental elements:

  • Main memory: Stores both data and instructions.
  • Arithmetic and Logic Unit (ALU): Capable of operating on binary data.
  • Control Unit: Interprets the instructions in memory and ensures their execution.
  • Input and Output (I/O) Equipment: Operated by the control unit to facilitate interaction with the external world.

Define the Two Main Categories of Processor Registers

Processor registers can be broadly classified into two categories:

  • User-Visible Registers: These registers are accessible to programmers using machine or assembly language. They help minimize references to main memory by optimizing register usage. High-level language compilers

... Continue reading "Understanding Computer Architecture: Key Components and Functions" »

Java Programming Concepts: A Comprehensive Guide

Classified in Computers

Written on in English with a size of 4.47 KB

  • A class is a template used to create objects and declare data types and methods in a program.
  • Public - Modifier used to declare classes and interfaces. Void - Method that returns no value. Main - Marks the start and end of program execution.
  • Scanner class - Used to get user input for types like String and Int.
  • Exceptions: Try-catch block, throw statement.
  • Inheritance provides a powerful and natural mechanism for organizing and structuring software programs. It improves clarity in the design of classes.
  • A subclass provides specialized behavior based on elements provided by the superclass. Using inheritance, programmers can reuse the code in the superclass many times.
  • Reading and Writing to Files:
    1. Import java.io file.
    2. File inputFile = new File("input.
... Continue reading "Java Programming Concepts: A Comprehensive Guide" »

Theory of Computation: Automata, and Regular Expressions

Classified in Computers

Written on in English with a size of 3.97 KB

Theory of Computation

Automata Theory

Automata theory is a theoretical branch of computer science and mathematics that deals with the logic of computation using simple machines called automata. The main goal of automata theory is to develop methods for describing and analyzing the dynamic behavior of discrete systems. Automata consist of states (represented by circles) and transitions (represented by arrows).

Finite Automata

A finite automaton is an abstract computing device and a mathematical model of a system with discrete input, output, states, and a set of transitions between states that occur on input symbols from an alphabet. Finite automata are the simplest machines for pattern recognition, used to characterize regular languages, analyze... Continue reading "Theory of Computation: Automata, and Regular Expressions" »

Data Manipulation and Visualization with R and the nycflights13 Dataset

Classified in Computers

Written on in English with a size of 3.64 KB

library(nycflights13)
library(tidyverse)

Data Manipulation with dplyr

Ordering Rows with arrange()

arrange(flights, year, month, day)
arrange(flights, desc(arr_delay))

Handling NAs

df <- tibble(x = c(5, 2, NA))
arrange(df, x)
arrange(df, desc(x))

Selecting Columns with select()

select(flights, year, month, day)
select(flights, year:day)
select(flights, -(year:day))
rename(flights, mes = month)
select(flights, time_hour, air_time, everything())

Creating New Variables with mutate()

flights_sml <- select(flights, year:day, ends_with("delay"), distance, air_time)
mutate(flights_sml, gain = arr_delay - dep_delay, speed = distance / air_time * 60)

Creating Functions with Vector Arguments

transmute(flights, dep_time, hour = dep_time %/% 100, minute = dep_time %
... Continue reading "Data Manipulation and Visualization with R and the nycflights13 Dataset" »

Digital Logic Design: Examples in VHDL

Classified in Computers

Written on in English with a size of 5.88 KB

Behavioral Architecture of a State Machine

This VHDL code describes the behavioral architecture of a state machine.

TYPE tipo_estado IS (DET0, DET0a1, DET1a0, DET1);
signal Estado_actual : tipo_estado;
signal Estado_siguiente : tipo_estado;
begin
Registro_estado: process (clk, reset)
begin
if reset='1' then Estado_actual <= DET0;
elsif (clk'event and clk='1') then
Estado_actual <= Estado_siguiente;
end if;
end process Registro_estado;
Cambio_Estado: process (Dato, Estado_actual)
begin
Estado_siguiente <= Estado_actual;
case Estado_actual is
when DET0 => if (Dato='1') then Estado_siguiente <= DET0a1;
else Estado_siguiente <= DET0;
end if;
when DET0a1 => if (Dato='1') then Estado_siguiente <= DET1;
else Estado_siguiente <= DET1a0;
end if;
... Continue reading "Digital Logic Design: Examples in VHDL" »

Microcontrollers: Architecture, Instruction Sets, and Interfacing

Classified in Computers

Written on in English with a size of 3.86 KB

Microcontrollers, Microcomputers, and Microprocessors

Microcontroller: Processor, memory, and I/O ports integrated on a single chip.

Microcomputer: A small computer.

Microprocessor: Example: Intel x86.

Von Neumann Architecture

Components:

  • Processor (Control Unit, ALU, Registers)
  • Memory (RAM - Volatile, ROM - Non-Volatile)
  • I/O

A single bus interconnects the processor, memory, and I/O.

RISC vs. CISC

FeatureCISCRISC
Instruction SetComplex Instruction Set ComputerReduced Instruction Set Computer
InstructionsMulti-cycle, complex instructionsMostly single-cycle, reduced instructions
Instruction TypesMany, varying lengthFew, fixed length
ComplexityHardwareSoftware
Code SizeSmallLarge
ExamplesIntel (x86), Freescale 9S12MIPS, ARM, SPARC, PowerPC

RAM vs. ROM vs. CPU Register

FeatureRAMROM
ElaborationRandom
... Continue reading "Microcontrollers: Architecture, Instruction Sets, and Interfacing" »

Colegio Leonardo Da Vinci: Noticias, Exámenes y Niveles

Classified in Computers

Written on in English with a size of 1.01 KB

Creative Commons License Icon

Logo Colegio Leonardo Da Vinci COLEGIO LEONARDO DA VINCI Sello Bilingüe

¡Hola, Muy Buenas!

Noticias Destacadas

COMIENZAN LOS EXÁMENES DE LA PRIMERA EVALUACIÓN.


EL BAILE DE DISFRACES DE HALLOWEEN FUE TODO UN ÉXITO.


LOS ALUMNOS PIDEN VER LOS PARTIDOS DE ESPAÑA EN CLASE.

La presente web no tiene derechos de autor, sino que está sujeta a la licencia Creative Commons mostrada.

Pascal Movie Database Management Procedures

Classified in Computers

Written on in English with a size of 8.83 KB

Pascal Movie Database Management

This document details several procedures written in Pascal for managing a movie database. The database is stored in a file of records, where each record represents a movie.

Data Structure

The code defines a pelicula (movie) record with the following fields:

  • codigo: integer (Movie ID)
  • genero: string (Genre)
  • nombre: string (Title)
  • duracion: integer (Duration)
  • director: string (Director)
  • copias: integer (Number of Copies)
  • precio: real (Price)

A constant valoralto is defined as 9999, used as a sentinel value.

And the file is defined as:

maestro= file of pelicula ;

Procedures

leerp(var p: pelicula)

Reads movie data from the input (keyboard) and stores it in the pelicula record p. It reads the codigo first. If it's not equal to... Continue reading "Pascal Movie Database Management Procedures" »