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

Sort by
Subject
Level

Advanced Web Design and JavaScript Exam Revision Sheet

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.65 KB

This revision sheet covers essential concepts for Advanced Web Designing and Advanced JavaScript exams, designed for effective last-minute study.


🧠 Advanced Web Design & JavaScript Revision

1. Fill in the Blanks (10 Marks)

  1. HTML stands for HyperText Markup Language.
  2. CSS is used for styling web pages.
  3. The <div> tag is a block-level element.
  4. The <span> tag is an inline element.
  5. External CSS files use the .css extension.
  6. JavaScript is a client-side scripting language.
  7. The <script> tag is used to embed JavaScript code in HTML.
  8. document.write() is used to print content on a web page.
  9. var, let, and const are used to declare variables in JavaScript.
  10. The href attribute is used in the <a> tag to link to another page.

2. True or False

... Continue reading "Advanced Web Design and JavaScript Exam Revision Sheet" »

Essential C++ Programming Examples and Code Snippets

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.19 KB

Palindrome and Digit Sum Calculation

#include <iostream>
using namespace std;
int main() {
    int n, r, rev = 0, sum = 0, t;
    cin >> n; t = n;
    while (n) {
        r = n % 10;
        rev = rev * 10 + r;
        sum += r;
        n /= 10;
    }
    cout << (t == rev ? "Palindrome" : "Not");
    cout << "\nSum=" << sum;
}

Matrix Addition in C++

#include <iostream>
using namespace std;
int main() {
    int a[10][10], b[10][10], c[10][10], r, col;
    cin >> r >> col;
    for (int i = 0; i < r; i++)
        for (int j = 0; j < col; j++) cin >> a[i][j];
    for (int i = 0; i < r; i++)
        for (int j = 0; j < col; j++) cin >> b[i][j];
    for (int i = 0; i < r; i+
... Continue reading "Essential C++ Programming Examples and Code Snippets" »

Understanding Servlet Architecture for Java Web Apps

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.4 KB

Understanding Servlet Architecture for Java Web Applications

Servlet architecture is a core component of Java EE (Enterprise Edition) used for building dynamic web applications. A Servlet is a Java class that runs on a web server and acts as a middle layer between client requests (typically from a browser) and server responses (usually from a database or application logic).

What is a Servlet?

A Servlet is a Java class used to handle HTTP requests and responses in web applications. It runs on a server, receives requests from a client (usually a browser), processes them (e.g., reads form data, interacts with a database), and sends back a dynamic response (like HTML or JSON).

Key Components of Servlet Architecture

  • Client (Browser): Sends an HTTP request
... Continue reading "Understanding Servlet Architecture for Java Web Apps" »

Essential C Programming Syntax and Memory Management

Posted by Anonymous and classified in Computers

Written on in English with a size of 62.93 KB

Operators

  • Arithmetic: +, -, *, /, %
  • Relation: ==, !=, >, <, >=, <=
  • Logic: &&, ||, !
  • Assignment: =, +=, -=, *=, /=, ?=
  • Increment: ++, --
  • Order of operations: (), *, /, %, +, -, <>, ==, !=

ASCII Conversions

  • Lowercase to uppercase: 'x' - 32
  • Uppercase to lowercase: 'x' + 32

Data Types

Data TypesExampleSizeFormat
intint age = 19;4 bytes%d
floatfloat a = 3.7;4 bytes%f
doubledouble pi = 3.1415;8 bytes%lf
charchar grader = 'a';1 byte%c
stringchar name[20] = "pierre";array%s

Constants

#define TAX 0.13
const int Max = 100;

Control Structures

Statements: if, else if, else

Switches

switch(x) {
    case 1: printf("One"); break;
    case 2: printf("Two"); break;
    default: printf("Other");
}

Loops: while, do while, for

For Loop Example

#include <stdio.
... Continue reading "Essential C Programming Syntax and Memory Management" »

Java OOP Concepts: Inheritance and Polymorphism Examples

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.1 KB

Single Inheritance in Java

Single inheritance involves one class inheriting properties and methods from exactly one parent class. Below is a demonstration using the Animal and Dog classes.

class Animal {
    Animal() {
        System.out.println("Animal constructor called");
    }
    void eat() {
        System.out.println("I can eat");
    }
}

class Dog extends Animal {
    Dog() {
        System.out.println("Dog constructor called");
    }
    void bark() {
        System.out.println("I can bark");
    }
}

public class Main {
    public static void main(String[] args) {
        Dog myDog = new Dog();
        myDog.eat();
        myDog.bark();
    }
}

Implementing Multiple Inheritance using Interfaces

Java does not support multiple inheritance... Continue reading "Java OOP Concepts: Inheritance and Polymorphism Examples" »

C# Design Patterns: Essential Reference for Developers

Posted by Anonymous and classified in Computers

Written on in English with a size of 12.41 KB

C# Design Patterns: Essential Reference

Creational Design Patterns

PatternWhen to UseKey Implementation
SingletonNeed exactly one instance globally accessible.private static Singleton _instance;
public static Singleton Instance => _instance ??= new Singleton();
FactoryCreate objects without specifying concrete classes.public static IProduct Create(string type) => type switch { "A" => new ProductA(), ... }
BuilderConstruct complex objects step-by-step.public class CarBuilder { ... public CarBuilder WithEngine(...) { ... } }
PrototypeClone existing objects instead of creating new ones.public interface IPrototype { IPrototype Clone(); }

Structural Design Patterns

PatternWhen to UseKey Implementation
AdapterMake incompatible interfaces work together.
... Continue reading "C# Design Patterns: Essential Reference for Developers" »

Essential C Programming Exam Questions and Solutions

Posted by Anonymous and classified in Computers

Written on in English with a size of 37.36 KB

x4jbIeyLsADAAAAAElFTkSuQmCC

Store Fibonacci Series in an Array

Exam Source: 2024 Q6(b)

Note: fib[0]=0, fib[1]=1, fib[i] = fib[i-1] + fib[i-2] for i >= 2.

#include <stdio.h>

int main() {
    int n, i;
    printf("How many terms? ");
    scanf("%d", &n);
    int fib[n];
    fib[0] = 0;
    if (n > 1) fib[1] = 1;
    for (i = 2; i < n; i++)
        fib[i] = fib[i-1] + fib[i-2];
    printf("Fibonacci series: ");
    for (i = 0; i < n; i++)
        printf("%d ", fib[i]);
    return 0;
}

Dynamic Memory Allocation and Average Calculation

Exam Source: 2024 Q7(c) / 2025 Q6(a) — Repeated both years!

Note: malloc returns void*, cast to int*. Always free() after use. If malloc returns NULL, memory allocation failed.

#include <stdio.h>
#include <stdlib.h&
... Continue reading "Essential C Programming Exam Questions and Solutions" »

Array and String Algorithms: Core Problem Solutions

Classified in Computers

Written on in English with a size of 6.48 KB


Longest Substring Without Repeating Characters

This problem involves finding the length of the longest substring in a given string that does not contain any repeating characters. A common approach uses a sliding window technique with a Set to efficiently track unique characters.

Strategy:

  • Utilize a Set to store characters within the current window.
  • Iterate through the string with a right pointer, adding characters to the Set.
  • If a duplicate character is encountered, move the left pointer forward, removing characters from the Set, until the duplicate is no longer present.
  • At each step, update the maximum length found.

Java Implementation Snippet

class Solution {
    public int findLongestSubstringWithoutRepeatingCharacter(String str) {
        Set&
... Continue reading "Array and String Algorithms: Core Problem Solutions" »

Tensors and Variables in PyTorch and TensorFlow

Classified in Computers

Written on in English with a size of 2.4 KB

Tensors and Variables in PyTorch and TensorFlow

Here's a brief explanation of tensors and variables in the context of deep learning frameworks like PyTorch and TensorFlow:

Tensors

  • Definition: A tensor is a multi-dimensional array used to represent data (such as scalars, vectors, matrices, or higher-dimensional data).
  • Common Operations: Tensors can be manipulated with mathematical operations (addition, multiplication, etc.), reshaped, sliced, etc.

In PyTorch, tensors are the core data structure:

import torch
# Create a tensor
a = torch.tensor([[1, 2], [3, 4]])
# Basic operations
b = a + 2         # Adds 2 to each element
c = a * a         # Element-wise multiplication
d = a @ a         # Matrix multiplication

Output:

Tensor `b`: [[3, 4], [5, 6]]
Tensor
... Continue reading "Tensors and Variables in PyTorch and TensorFlow" »

Assembly Language Fundamentals: Registers, Operands, and Data Types

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.73 KB

Assembly Language Fundamentals: Key Concepts and Definitions

1. Clock Frequency and Cycle Time

A clock that oscillates 1 million times per second (1 MHz) produces a clock cycle duration of $10^{-6}$ seconds (1 microsecond).

2. General-Purpose Registers (8-bit, 16-bit, and 32-bit Access)

The general-purpose registers that can be accessed in 8 bits, 16 bits, and 32 bits are: EAX, EBX, ECX, and EDX.

3. Purpose of EAX and ECX Registers

These registers serve specific roles in CPU operations:

  • EAX – Accumulator: Automatically used by multiplication and division instructions. It is often referred to as the extended accumulator register.
  • ECX – Loop Counter: The CPU automatically uses ECX as a counter for loop instructions.

4. Reserved Words and Identifiers

... Continue reading "Assembly Language Fundamentals: Registers, Operands, and Data Types" »