--Originally published at Franco TC1017

This program is similar to WSQ 01 but, instead of writing the direct operations, it calculates the sum, difference, product, quotient and residue through functions.

This link was really helpful to write this program.

I’d like to share my favorite quote from Bertrand Russell.

Mathematics, rightly viewed, possesses not only truth, but supreme beauty—a beauty cold and austere, like that of sculpture, without appeal to any part of our weaker nature, without the gorgeous trappings of painting or music, yet sublimely pure, and capable of a stern perfection such as only the greatest art can show.”
― Bertrand Russell, A History of Western Philosophy.


On to Functions code

WSQ05 – On To Functions!!!!!

--Originally published at blog de Horacio

What to Do:

You will go back and do WSQ01 – Fun with Numbers again.

But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.

You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.


fist we need to search wsq01 homework for remind how do this exercise, but now we have to change de variables into a functions.

Then we had to look for reliable sources on the subject of functions so as to know which methodology to carry out this challenge, finally as we did this task previously, we just have to change that part of functions.


include <iostream>
using namespace std;

int sum(int x, int y){
return (x+y);

int Difference (int x, int y){
return (x-y);

int Product (int x, int y){
return (x*y);

int Division (int x, int y){
return (x/y);

int Remainder (int x, int y){
return (x%y);

int main()
int x,y;
cout << “este programa tiene una funcionalidad similar al WSQ01 pero ahora todo integrado en funciones” << endl;

cout << “teclea el primer numero a evaluar” << endl;
cin >> x;
cout << “teclea el segundo numero a evaluar” << endl;
cin >> y;

int r1 = sum(x,y);
int r2 = Difference(x,y);
int r3 = Product(x,y);
int r4 = Division(x,y);
int r5 = Remainder(x,y);

cout << “la suma de los dos numeros es: ” << r1 << endl;
cout << “la resta de los dos numeros es: ” << r2 << endl;
cout << “la multiplicacion de los dos numeros es: ” << r3 << endl;
cout << “la

Continue reading "WSQ05 – On To Functions!!!!!"

Coming back to life.

--Originally published at

This is the blog related to WSQ05, in this program, we were asked to go back in time, to when we were just starting the course.

The original code looked like this:

#include <iostream> /* This will include the library to call functions like
cout, cin */

using namespace std; /* This allows me to avoid writing std:: before
every function */

//Declare a whole variable
int none, ntwo;

//This is the beggining of the program.
int main (){

cout << "Insert a number: "; //Here I'm asking the user to insert a number cin >> none; //The answer of the user is stored in the previously declared variable "none"
cout << "Insert another number: "; //Here I ask the user to insert another number cin >> ntwo;

/* In this part, the program will add, subtract, multiply, divide and give back the remainder */
cout << "The sum of: " << none << " + " << ntwo << " is: " << none + ntwo << endl;
cout << "The difference of: " << none << " - " << ntwo << " is: " << none - ntwo << endl;
cout << "The product of: " << none << " * " << ntwo << " is: " << none * ntwo << endl;
cout << "The division of: " << none << " / " << ntwo << " is: " << none / ntwo << endl;
cout << "The remainder of: " << none << " / " << ntwo << " is: " << none % ntwo << endl;


As you can see, everything is in the main(), as Ken told me last class, we need to make functions because they are like lego blocks and they can be placed in different programs

Continue reading "Coming back to life."

cout<< “Starting Again” <<endl;

--Originally published at Alvaro_246


En el WSQ05 hice lo mismo que en el WSQ01,un programa que hiciera las cuatro operaciones básicas de una calculadora, pero esta vez cada una de las operaciones matemáticas que tiene el programa (Suma, Resta, Multiplicación y División) son funciones llamadas de diferente manera ” Int nombre de la función(Int valor1, valor2) { return (Formula de la función). Mi programa solo funciona con números enteros, por que utilice Int y no float.


Homework 5 On to functions

--Originally published at Solving problems with programming

This homework is very easy, it is about a old WSQ were we have to do many operations with the same 2 variables, but instead of writting the procedures in the main function we are going to make a function to each operation and then call it int he main function

Heres the code of WSQ05 and the code of WSQ01 or the blogpost Fun With Numbers, so you can see the difference

#include <iostream>
#include <stdlib.h>
using namespace std;
int suma(int numero1, int numero2){
int resultado;
resultado = numero1 +numero2;
return resultado;
int resta(int numero1, int numero2){
int resultado;
resultado = numero1-numero2;
return resultado;
int multiplicacion(int numero1, int numero2){
int resultado;
resultado = numero1*numero2;
return resultado;
int division(int numero1, int numero2){
int resultado;
return resultado;
int residuo(int numero1,int numero2){
int resultado;
return resultado;
int main()
int num1, num2, res;
cout <<“Escribe número 1 ” <<‘\n’ ;
cin >> num1;
cout <<“Escribe numero 2 ” <<‘\n’;
cin >> num2;
res = suma(num1,num2);
cout <<“Suma = “<<res<< ‘\n’;
res = resta(num1,num2);
cout <<“Resta = “<<res<< ‘\n’;
res = multiplicacion(num1,num2);
cout <<“Producto = “<<res<<‘\n’;
res = division(num1,num2);
cout <<“Division = “<<res<<‘\n’;
res = residuo(num1,num2);
cout <<“Residuo = “<<res<<‘\n’;


Volver a empezar pero ahora con funciones WSQ05

--Originally published at Hensel

En esta ocasión volví a realizar el código WSQ01, solo que ahora para cada operación utilice una función y utilice “if” para que el código determinara que operación fue designada por el usuario..wsq051

En esta parte se puede ver como realice cada operación utilizando funciones, para la operación de suma cree la función SUM_OF_NUMBERS, para la resta fue REMAINDER_OF_NUMBERS,para la multiplicación PRODUCTS_OF_NUMBERS, la división es DIVISION_OF_NUMBERS y finalmente para obtener el residuo de una división es RESIDUE_OF_DIVISION.


Aquí es en donde comienza el programa declaramos las variables num1 y num2 y se despliega un mensaje en pantalla junto con un menú, en donde el usuario deberá ingresar el numero correspondiente a la operación que quiere realizar. Una vez seleccionada la operación, esta se guarda dentro de una variable llamada “answer”, después solicita ingreses el primer numero que se guardara dentro de una variable llamada “num1”, vuelve a mostrar otro mensaje pero ahora te pide un segundo numero con el cual realizara la operación previamente seleccionada y guardara el dato ingresado en una variable llamada “num2”.

Una vez ingresados los datos, el programa comparará la variable “answer” para determinar que operación realizar. Después de encontrar la operación, llamara a la función correspondiente dentro de ese “if”. A continuación puedes ver como funciona el programa ya terminado.




--Originally published at OlafGC / Class #TC1017

#include <iostream>
#include <cmath>
using namespace std;

int sum(int n1, int n2)
int dif(int n1,int n2)
int pro(int n1, int n2)
int divi(int n1, int n2)
int mod(int n1, int n2)

int main()
int n1,n2;
cout<<“This program gives you the sum, difference, multiplication, division and the remainder of two given numbers.”<<endl;
cout<<“Please insert the first number:”<<endl;
cout<<“Please insert the second number:”<<endl;
int s=sum(n1,n2);
int d=dif(n1,n2);
int p=pro(n1,n2);
int di=divi(n1,n2);
int m=mod(n1,n2);
cout<<“The result of the sum is “<<s<<“.”<<endl;
cout<<“The result of the difference is “<<d<<“.”<<endl;
cout<<“The result of the product is “<<p<<“.”<<endl;
cout<<“The result of the division is “<<di<<“.”<<endl;
cout<<“The remainder of the division is “<<m<<“.”<<endl;
return 0;

WSQ – 05, the number 1 but with a function

--Originally published at The Clueless Programmer

So this WSQ was easy because I esencially had already done this assignment. All I had to do was return to the first WSQ and just expand it by adding a function that did all of the operations that happened in the main program. So here you have the code:

#include <iostream>
using namespace std;
int sdpir (int a, int b, int res)
cout<<“The sum of the integers is “<<res<<endl;
cout<<“The difference of the integeres is “<<res<<endl;
cout<<“The product of the integers is “<<res<<endl;
cout<<“The integer based division is “<<res<<endl;
cout<<“The remainder integer of the division is “<<res<<endl;
int main()
int num1, num2, res;
cout<<“Please enter a number “<<endl;
cout<<“The number you entered is “<<num1<<endl;
cout<<“Please enter a second number “<<endl;
cout<<“The number you entered is “<<num2<<endl;
sdpir(num1, num2, res);

So as you can see the first thing I do is name a functionthat calls 3 ints, two that I will be using to make opperations and one that is going to print the result. As you can see I just do the five opperations and print them all in the same variable, this is optional but I do it like this to reduce the variables and make it easier.

After the function is done I just go to the main program in which I basically ask the user to give me two numbers, then I execute the function and done, I have all the results I wanted in a “smaller” code.

Thanks for reading this awesome blog (it is pretty bad actually) again and as always I hope that I could´ve been of some help. Program on.