On to Functions

This program is like one in the WSQ03 but this time we have to add functions to each one.

Had a little problems because I didnt know how to add functions but I read in cplusplus.com something about functions and then I look for a youtube video so taht I can make it rigth, below I attacht the links to the cplusplus webpage of functions and the youtube video for your need.


So here I have my Atom for you to see how it looks



Then I show you the terminal page to you to see how the program works


Check my code here on Github.

WSQ08 – on to the functions

This program should give you the same results as the WSQ03 but using function for each operation.

Captura de pantalla 2016-02-16 a las 8.59.42Captura de pantalla 2016-02-16 a las 8.59.47So basically, I write single functions, to the sum, product, difference, and division operations. Using void instead of int. And this was kind of quickly because I just copy the main code from de WSQ03, and then I started to editing what I needed.

Here’s the link to my GitHub.

WSQ08 – On To Functions


WSQ03These activities were about creating a program in which they calculate the division, sum, difference and the division remainder of two given numbers. It didn’t ask you to do it with function but I did anyways and that was asked in WSQ08. Everything is better if you use functions, for this you have to define your variables. To do this activity I had to check how to define a function, and now I know that you can define it with int, float, long, char.

Using functions

This WSQ was about using the WSQ3 made before but changing it, now using functions for making each calculation.

As I didn´t know how to make functions on c++ I search for it and foun this page that helped my doing this program. (Here).

For each of the operations I needed to use:

int TheOperation (int x, int y)
{int a;
a = x (-/*%) y;
return a; }

And just at the end instead of using:
cout <<“The difference of these two numbers is: “<<resta;  I just added the two numbers. Ex: cout <<“The difference of these two numbers is: “<<resta (number1,number2);

This was made for all the operations.
You can see my program here: funtions. Feel free for using it.

This are some pictures of my program:

Haga click para ver el pase de diapositivas.


Éste es un programa para calcular el resultado de 4 operaciones: La resta, multiplicación, división y module. Cómo se puede observar, éste no es un programa común y corriente, pues para realizarlo se utilizaron funciones. ¿Que son funciones? Una función es un conjunto de líneas de código que realizan una tarea específica y puede retornar un valor. Las funciones son utilizadas para descomponer grandes problemas en tareas simples y para implementar operaciones que son comúnmente utilizadas durante un programa y de esta manera reducir la cantidad de código. Dicho lo anterior, desde la linea 6 hasta la linea 16 son las funciones que están llevando a cabo las operaciones que están dentro del int main. Como se puede ver, se poner el nombre de la función, puede ser cualquiera poniéndole int o float o el que se requiera usar, seguido va un paréntecis que engloba las variables que se utilizan en esa función, igualmente especificando el tipo de variables que son, y por ultimo, se debe poner la palabra return y entre paréntecis la operación con dichas variabls que quieras que sea resuelta entre ellas, como se puede observar en las lineas 7,10,13 y 16. Dentro del main, debes poner lo de siempre, pedir las variables al usuario e imprimir en cout por ejemplo, cout<<“El resultado de la resta es: ” y seguido de éste debes mandar llamar la función, como en este caso estamos hablando de la resta, nuestra función se llamó oprest, así que la mandamos llamar así: oprest (a,b) porque a,b? porque si recordamos utilizamos “x” y “y” pero para no mezclar variables abajo las nombramos con otro nombre y las mandamos llamar, en vez de “x” como “a” y en vez de “y” como “b”, no tienen que ser esas letras, pueden ser las que tu



#WSQ08 On to functions.


Hello people! I made a new program about functions, and yes, it’s the same program as the WSQ03, but now using Functions. What is a function on C++? “In C++, a function is a group of statements that is given a name, and which can be called from some point of the program. The most common syntax to define a function is:

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) ”

(you can find more interesting information here: http://www.cplusplus.com/doc/tutorial/functions/)

And well, that page helps me a lot making my work easier, and as I sayed before, it was a remake of an old program so it was not difficult for me.

Here, the screenshots of my code using functions:

Haga click para ver el pase de diapositivas.

Here the program on Cygwin Terminal:


And that’s all.

The functions help us to make our program clear and more easy to understand. We cant forget that to put the “RETURN” at the end of the function to make it workable.

Hope you like it!

Don’t forget to see my codes on GitHub. Click here to see them.



Functions? …

Photograph credit

Hey there, catching up on some WSQs, this is WSQ08 I believe and in this program we have to do the same as WSQ03 but with a twist. We have to add functions to the program. But what are functions and how do we use them? Well continue with the video to find out.

Ohh! but before that just let me mention my favorite page sources for finding out how to do stuff on c++



Here is the code, the simple and complex respectively:




WSQ08 Functions

The functions allow to structure programs in segments of code to perform individual tasks.

In this program I´m going to do the same as in the WSQ03, but using functions.

You have to enter two numbers and the program will calculate:

  • The difference of the two numbers.
  • The product of the two numbers.
  • The integer based division of the two numbers (so no decimal point). First divided by second.
  • The remainder of integer division of the two numbers.


Captura de pantalla 2016-02-09 a las 11.05.07 a.m.Captura de pantalla 2016-02-09 a las 11.05.10 a.m.Captura de pantalla 2016-02-09 a las 11.05.23 a.m.

I will leave the code on GitHub, here is the link.