Arrays

Hi there, today I´m gonna show you something useful, how to use arrays. An array is basically something like a list in which you can storage information.

Here is an example:

Captura de pantalla 2017-05-03 a la(s) 23.55.22

In that code you can see that it will storage a number in an specific part of the array.

I hope it helps. See you around!

For

If you remember earlier I showed you how to use do and while, right now I will show you how to use for for loops. It is quite easy, you just write for (something that will be done at the first run of the program; the condition that will keep the program running; what will be executed in each run)

Here is an example:

Captura de pantalla 2017-05-03 a la(s) 23.47.31

Also you can use a for inside another for, like in this example, here it will print some “T”.

Use it well. See you around!

do and while

Hi there, I have something interesting today, I will show you how to use do and while, which basically is like a loop that will keep doing something until a condition is met and then it will stop. Here is an example

Captura de pantalla 2017-05-03 a la(s) 23.42.01 This isa very simple code that will print five run five times and will print “I like this posts” five times.

You can use this in many different ways. See you around.

“If” nesting

Hi there! In the previous post I showed you how to use “if” and “else”, but what if I told you that you can put if inside if another if? Thats insane right?

Well, it is very simple to use, it is the same thing as using a normal “if”, but you will put another one inside of that one.

Heres an example:

Captura de pantalla 2017-03-29 a la(s) 10.55.22

Basically if the condition is met, the code will execute, if it isn´t, the next condition will pop and it will continue to work.

“If”

Hi there! Today I am gonna teach you how to use the  condicional “if”. This “if” is a condicional, meaning that you will establish a condition that will have to be accomplished for your code inside if it to be executed.

It is very simple to use you will just put:

 

Captura de pantalla 2017-03-29 a la(s) 10.30.01

That is the basic syntaxis for using an if. Meaning that you put if, the condition that will have to be accomplished, then the code that will be executed if thats the case.

I included something else here, the “else”, this will help you do many different things. You use your “if” in a normal way, but then you can use “else” to make your program do something else if the condition is not met.

Captura de pantalla 2017-03-29 a la(s) 10.40.11

Libraries

So, libraries are basically code that have been written by someone else that you can use in yours so you don´t need to actually write all of it.

There are some basic libraries that you can use. Here is a list of them and for what specific thing you use them.

functions:

Containers

Input/Output Stream Library

Provides functionality to use an abstraction called streams specially designed to perform input and output operations on sequences of character, like files or strings.
This functionality is provided through several related classes, as shown in the following relationship map, with the corresponding header file names on top:

iostream

Atomics and threading library

Miscellaneous headers

Each library has the link to more information about them. Enjoy.

Functions

Hi there! Today I have something that will help you very much in making big programs. This are functions.

A function is basically is a statement with a name that can be called later in the program. What I mean with this is that you make part of the program that can be filled with some information and then call that little segment and use it for something else.

This is how you create a function:  type name ( parameter1, parameter2, …) { statements }

In which type is the type of the value returned by the function.
name is the identifier by which the function can be called.
parameters (as many as needed): Each parameter consists of a type followed by an identifier, with each parameter being separated from the next by a comma. Each parameter looks very much like a regular variable declaration (for example: int x), and in fact acts within the function as a regular variable which is local to the function. The purpose of parameters is to allow passing arguments to the function from the location where it is called from.
statements is the function’s body. It is a block of statements surrounded by braces { } that specify what the function actually does.

And here is an example:

// function example
#include <iostream>
using namespace std;

int addition (int a, int b)
{
  int r;
  r=a+b;
  return r;
}

int main ()
{
  int z;
  z = addition (5,3);
  cout << "The result is " << z;
}
The result is 8

You can find more info in here http://www.cplusplus.com/doc/tutorial/functions/