WSQ_05_On_To_Functions

--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.  http://www.cplusplus.com/forum/beginner/44001/

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


#WSQ10

--Originally published at May The Code be With You

Hello, Young Padawans!

Today, we are going to calculate a square root using an unconventional method, the Babylonian Method.

You may ask “What the heck is a Babylonian?!”. Well, Babylonials were an ancient culture who gave a lot to our math knowloge, by creating methods like this to calculate certain things.

This particuliar method consist in cutting a rectangle until it gives you the closest number to a square. Of course we are not cutting anything, we will just follow the formula.

More info here: https://mathlesstraveled.com/2009/05/18/square-roots-with-pencil-and-paper-the-babylonian-method/

So, the formula basically says “Take the number you want to know its square root, add the closest perfect square number to it. And divide all that by the square root of the perfect square number multiplied by two”

what

I know it may sound a little complicated, but here is a video to explain it in a simplier way: https://www.youtube.com/watch?v=sFMK3v879kg

babylon

As a human, you have a natural sense of comparission between number, so in that way you can know which perfect square number to use, but in your program you will have to make a for loop and increase the number and multiply it by itself in order to get the closest one, simple.

Hope It can help you.

keep


Quiz_8

--Originally published at May The Code be With You

Hello, Young Padawans!

This time I´ll teach you how to get through quiz#8.

The main topic of this quiz is the Fibonacci Series. A special serie where the two previous numbers summatory gives you the next number. You can see it here:

http://www.disfrutalasmatematicas.com/numeros/fibonacci-sucesion.html

Knowing this is quite simple how to do it.

quiz8

As you can see, since the series starts with 0, if the user ask you for the first term, you will have to return 0, and also for the second and third term you will have to use ifs in order to return “1”.

And for any other term just use the formula.

Simple

kronk


Expo Ingenierías

--Originally published at prgrm.co

So I went to Expo Ingenieria and I felt motivated. People my age are making some amazing things, so I felt the need to do something amazing. I tried to make an engine that would spin at different speeds but I couldn’t make it work. But seeing all of what my classmates are doing made me realize I want to be doing cool things as well. I saw a 3d prosthesis and a lot of robotic arms.


Use of diferent Functions

--Originally published at how not to program

Here is a code showing diferent functions

#include <iostream>
using namespace std;

int num1, num2, res, dif, mul;
float div;
int resta(int a, int b)
{
dif = a – b;
return (dif);
}
int mult(int a, int b)
{
mul = a * b;
return (mul);
}
int residuo(int a, int b)
{
res = a % b;
return (res);
}
float division(int a, int b)
{
div = a / b;
return (div);
}

int main(){
cout << “Introduce dos numeros. ” << endl;
cin >> num1 >> num2;
cout << “La resta es: ” << resta(num1,num2) << endl;
cout << “La multiplicacion es: ” << mult(num1,num2) << endl;
cout << “El residuo es: ” << residuo(num1,num2) << endl;
cout << “La division es: ” << division(num1,num2) << endl;
return 0;
}