C Programming Examples: Data Structures & Algorithms
C Programming Examples: Data Structures and Algorithms
This document presents a collection of fundamental C programming examples, covering essential data structures and algorithms. Each section includes a C code implementation along with a brief explanation of its functionality.
1. String Length and Concatenation in C
This C program demonstrates how to calculate the length of a string and concatenate two strings without using built-in library functions like strlen()
or strcat()
. It provides a menu-
Object-Oriented Concepts and UML Diagrams Explained
Object-Oriented Concepts
Object: An object is anything that we can recognize with an identity, a state, and behavior.
Class: It is an abstraction representing a set of objects with similar behavioral characteristics.
Use Cases
Use Case: A sequence of interactions (user-software product) to meet requirements.
Actor: Anyone who needs to meet their requirements. There may be 3 types:
- Main: The one who initiates the use case and needs to fulfill its requirements.
- Partner: An actor interacting with the principal
Validação de Formulários HTML com JavaScript e Regex
Validação com Expressões Regulares (Regex)
Validar Apenas Números
Expressão regular para checar se o campo possui apenas números.
function validaApenasNumero() {
var regex = /^\d+$/;
var value = document.getElementById("name1").value;
if (regex.test(value)) {
alert("Correto");
return;
}
alert("Errado");
return;
}
Nome: Ok
Validar Apenas Letras
Expressão regular para checar se o campo possui apenas letras.
function validaApenasLetras(){
var regex = /^[a-zA-Z]+$/;
// Corrigido:
Read More
Understanding Use Cases, Object Interaction, and Domain Models
Understanding Use Cases
Use Case: A business process that begins and ends with an actor, accomplishing a business task for that actor.
Components:
- Operation: A series of actions or instructions to accomplish a step in a business process.
- Action: An indivisible act, movement, or instruction performed during an operation.
Steps in Use Case Development
- Identifying use cases: deriving use cases, actors, and subsystems.
- Rearranging use cases among subsystems.
- Constructing a traceability matrix.
- Specifying use
Domain Modeling: Key Concepts and UML Representation
Domain Model and Cartographer Strategy
The construction of a Domain Model (DM) is compared to a cartographer’s strategy because of the following reasons:
- Existing Names: A DM should use the existing names within a territory. It utilizes the vocabulary of the domain, including conceptual classes and attributes.
- Relevance: A cartographer removes elements from a map if they are not considered relevant to the map’s purpose. Similarly, a DM may exclude conceptual classes from the problem domain that are
C Code Examples: Neurons, Vectors, and ID Validation
Neurons
The following C code demonstrates a simple neuron activation function.
#include <stdio.h>
int main() {
int entry[5], weights[5], limit, and;
putchar('\n');
for (int i = 0; i < 5; i++) {
printf("Entry%d: ", i);
scanf("%d", &entry[i]);
}
putchar('\n');
for (int i = 0; i < 5; i++) {
printf("Weight%d: ", i);
scanf("%d", &weights[i]);
}
putchar('\n');
printf("Limit: ");
scanf("%d", &limit);
Read More