Daniel de la Cruz Calvo
Software Engineer and professional mentor for developers.
Engineering is the application of scientific, economic, social, and practical knowledge in order to invent, design, build, maintain, research, and improve structures, machines, devices, systems, materials and processes.
c#
We can classify programming languages according to the level of abstraction of the commands we can give to the machine's hardware
We can classify programming languages according to the level of abstraction of the commands we can give to the machine's hardware
telling the "machine" how to do something, and as a result what you want to happen will happen.
var numbers = [1,2,3,4,5]
var doubled = []
for(var i = 0; i < numbers.length; i++) {
var newNumber = numbers[i] * 2
doubled.push(newNumber)
}
console.log(doubled) //=> [2,4,6,8,10]telling the "machine" what you would like to happen, and let the computer figure out how to do it.
var numbers = [1,2,3,4,5]
var doubled = numbers.map(function(n) {
return n * 2
})
console.log(doubled) //=> [2,4,6,8,10]SELECT * from dogs
INNER JOIN owners
WHERE dogs.owner_id = owners.id//dogs = [{name: 'Fido', owner_id: 1}, {...}, ... ]
//owners = [{id: 1, name: 'Bob'}, {...}, ...]
var dogsWithOwners = []
var dog, owner
for(var di=0; di < dogs.length; di++) {
dog = dogs[di]
for(var oi=0; oi < owners.length; oi++) {
owner = owners[oi]
if (owner && dog.owner_id == owner.id) {
dogsWithOwners.push({
dog: dog,
owner: owner
})
}
}}
}#include <stdio.h>
void main()
{
/* Starting program execution */
int a, b, c = 5;
a = 3 * c;
b = 32 / 4;
c = a − b;
printf("Valor resultante: %d\n", c);
}int numero = 1;
// Unary operators
numero++; // 2
numero--; // 1
-numero; // -1
// Binary operators
numero + 3; // 2
numero % 2 // 0
numero - 1; // -1
numero * -5; // 5
numero / 5; // 1
// Join expressions
(numero * 10) + 2; // 12
((numero++) + 1) / 2; // 7int uno = 1;
int dos = 2;
uno < dos; // true
uno > dos; // false
uno > 1; // false
uno >= 1; // true
uno <= 1; // true
uno == 1; // true
uno != dos // true Executing a group of sentences or another, depending on the result of evaluating a conditional expression
int numero = 10;
if(numero == 10)
{
Console.WriteLine("Número es igual a 10");
}int numero = 9;
if(numero == 10)
{
Console.WriteLine("Número es mayor que 10");
}
else
{
Console.WriteLine("Número no es igual a 10");
}int numero = 9;
if(numero == 10)
{
Console.WriteLine("Número es mayor que 10");
}
else if(numero == 9)
{
Console.WriteLine("Número es igual a 9");
}
else
{
Console.WriteLine("Número no es igual a 10 ni tampoco a 9");
}int numero = 9;
switch(numero)
{
case 10:
Console.WriteLine("Número es igual a 10");
break;
case 9:
Console.WriteLine("Número es igual a 9");
break;
default:
Console.WriteLine("Número no es igual a 10 ni tampoco a 9");
break;
}int numero = 9;
switch(numero)
{
case 10:
case 9:
Console.WriteLine("Número es igual a 9 o a 10");
break;
default:
Console.WriteLine("Número no es igual a 10 ni tampoco a 9");
break;
}int numero = 9;
bool esNueve = numero == 9 ? true : false;
if(esNueve)
{
Console.WriteLine("Número es igual a 9");
}int numero = 9;
if(numero == 9 && numero == 10)
{
Console.WriteLine("OK");
}
if(numero == 9 & numero == 10)
{
Console.WriteLine("OK");
}
if(numero == 9 || numero == 10)
{
Console.WriteLine("OK");
}
if(numero == 9 | numero == 10)
{
Console.WriteLine("OK");
}Write a program that reads three integer numbers and writes in console the maximum and minimum values.
Given two sides of a rectangle, calculate the area and perimeter and print them in console
Given a number of seconds, print in console how many days, hours, minutes and seconds correspond
while(condition)
{
// group of sentences
}do
{
// group of sentences
}
while(condition);for(initial_sentence; break_condition; incr/decr) {
// group of sentences
}do {
if (num < 0) {
{
Console.WriteLine("The number can't be negative");
break;
/* leaves the iteration. */
}
if (num > 100) {
Console.WriteLine("The number is too big");
continue;
/* Don't execute the rest of sentences and breaks the iteration */
}
...
} while (num != 0 );Text
Write a program to calculate the sum of every multiples of 5 between two given numbers
A function is a reusable block of code that performs one specific task.
also known as methods, procedures or routines
int Square(int x) {
return x * x;
}void printInConsole(string message){
console.log("MESSAGE: " + message);
}
...
printInConsole("Hello World!");
...
$ MESSAGE: Hello World!if (value > 5) {
console.log("value is greater than 5");
}
if (value > 6) {
console.log("value is greater than 6");
}
if (value > 7) {
console.log("value is greater than 7");
}
if (value > 8) {
console.log("value is greater than 8");
}void valueIsGreaterThan(value, comparator) {
if(value > comparator) {
console.log("Value is greater than " + comparator);
}
}
...
valueIsGreaterThan(10, 5);
valueIsGreaterThan(10, 6);
valueIsGreaterThan(10, 7);
valueIsGreaterThan(10, 8);
valueIsGreaterThan(10, 9);
A software entity should never have more than one reason to change.
By Daniel de la Cruz Calvo
Work in progress: Computer fundamentals lessons for people who want to start learning programming.
Software Engineer and professional mentor for developers.