Estimating e

--Originally published at ordinary & extraordinary

In this assignment I had to create a function that calculates the mathematical constant e, and the show it on screen with the precision that the user wanted to see. What the function does is to divide 1 by the factorial 0 and then it does it again with the next factorial, but every time it does it, it sum the new division plus the e, and in stops when the remain of the rest of the e minus the previous e is equal to the precision that the user introduce. I love to work with numbers, is one of the things I most enjoy.  #WSQ12 #functions #math

Click here to see my code ?

Captura de pantalla 2017-11-29 a las 14.11.55Captura de pantalla 2017-11-29 a las 14.12.14Captura de pantalla 2017-11-29 a las 14.12.44Captura de pantalla 2017-11-29 a las 14.12.59


End of the course…

--Originally published at ordinary & extraordinary

Hey!! I’m about to finish my first semester of my career. It has being been a really good semester: I met a lot of nice people, I made really good friends, I liked my classes and I got good grades. This is just one step more to get my goals, and I have to take advantage of every opportunity because time never stops. About this course: Solving problems with programming, I liked everything, some of the assignments were more difficult, but even if they took me a lot of time, I enjoyed every minute I took to make them. I learned a lot. 

Here I let you a video were I explain more about how this course was to me. 

Hope you like it. And thank you Ken for everything. ? 

Sofía González.


SciLab√±−×÷

--Originally published at ordinary & extraordinary

This las assignment was different of all of the rest I have made, this one was not about to create a code that does something; it was about work with a really useful tool: Scilab. In this activity I worked with some friends (Brenda Ruíz, Oscar Ramírez and Ana González), cause my computer and ome others had problems with using SciLab.

Scilab is a mathematics software, in which, with the help of programming, we can make maths calculations. This will help us a lot because we are studying Mecathronics.

You can read more about this activity in Oscar’s Blog .

#WSQ13 #maths #programming


Go Bananas±

--Originally published at ordinary & extraordinary

What I have to do in this assignment was to create a program that read a file and look for how many times the word banana were in that. This was a little difficult for me because I don’t know a lot how to work with files, but I liked it because I learned a lot. I had to use the function that is already made getline to go to each line of the text. This is a really interesting program. #WSQ11 #files #lines #words

Click here to see my code ?

 

 

 


Project ◊

--Originally published at ordinary & extraordinary

For my project a made team with my sister Ana Paula. The first idea of our project was to create a sudoku game, we investigated about it and it wasn’t as difficult as we thought it would be, but we realized that it would take a lot of time; so we decided to create a program were the user can do some magic squares. We thought that magic squares are similar than the sudoku game, that’s why we decided to make it. As you can see we love numbers and mental games. 

Well, first, what this program does is to ask the user which square he want to complete, if one 3×3 or one 4×4, then the user has to choose an level of four different possibilities, and finally the user has to introduce the numbers remaining in the square. At the end the program tells you if the square is correct or incorrect. 

Here is the link where you can see our code: https://github.com/SofiaGo32/WSQ-17/blob/master/magicsquare34.cpp

Hope you like it… ♥


Babylonian Method √

--Originally published at ordinary & extraordinary

This program is really interesting, it looks really easy, but the Babylonian method is a little weird. I think this shows how mathematics has been developing along the years, and in some parts is easier. Well, instead there is already a function that calculates the square root of a number I had to create a program that calculates the square root of a number that the user introduces by the Babylonian method. I like to work with numbers, some times is easier, but other times is more difficult, but I like to think how to make and find a solution. This one was not too difficult, I created a functiΓon that receives two numbers, both numbers are introduced by the user; the first one is the number which the user wants to know its square root; the other one is an initial guess of the user of which could be the square root of that number. What the function does is to divide the number by the guess, then add the guess to the result and then multiply it by 0.5, this new value will be stored in the variable of the guess, because we want to have this new value in its place every time it enters to the loop; it will enter to the loop until the difference of the new value and the value before it is really small, like .0001. In your main program, you only call the function and assign the two values you want to enter in it and then you show the result at the end. And this is how Babylonians get the square root of a number. ? #WSQ10 Captura de pantalla 2017-10-26 a las 22.02.41Captura de pantalla 2017-10-26 a las 22.03.21Captura de pantalla 2017-10-26 a las 22.04.02


Multipart Data and Files Ξ

--Originally published at ordinary & extraordinary

This task was about to create a program which could read a text file and showed on screen the numbers of lines and the numbers of characters that were on that file. First I had to investigate how to work with files in c++, I had never worked with files in any language so it was new for me. To get it I searched on the Internet and asked some of my classmates. After that the rest of the program was easier. There is already a function that counts the length of a line, so the only thing that I had to do, was to sum each length of all the lines. To count the number of lines I used the function getline, and the counter was increasing one by one until there was no lines. The other difficult part was to calculate and return both calculations in just one function. In this part my professor Ken helped me and he told me to use struct, what this does is to put your values like in a box and then show that box, so it is showing just one thing that contains in it more things. And that’s it. Below here you could see how it works; hope you like it.  #WSQ9 #files #strcut #stringCaptura de pantalla 2017-10-26 a las 22.01.13Captura de pantalla 2017-10-26 a las 22.02.18


Yo soy 196 ⇔

--Originally published at ordinary & extraordinary

Ken said that it was the most difficult program of the semester, I tried to make it and I think I got it. To write this program I spent a lot of time. First I created a function to reverse a number, I investigated a little to know how to do that, I did it really fast, I think this was the easier part. I also created three variables the first to count the numbers of palindromes in the series of numbers, the second to count the numbers of nonlychrel and the other one to count the numbers of lychrel candidates. After that, inside my program the first thing it does is to compare the number with its reverse, and if there are equal it add 1 to the counter of the palindromes; if not it enters to a loop, what occurs in this loop is that it will sum the number plus its reverse, then compare the result of the sum with its reverse, if they are equal it will add 1 to the counter of nonlychrel if not, it will do this up to 30 times; if after this 30 times the numbers were not equal it will add 1 to the counter of lychrels, then it passes ⇔to the next number and so on. #WSQ8 #nestedloops #dowhile Captura de pantalla 2017-10-26 a las 22.52.56Captura de pantalla 2017-10-26 a las 22.53.04Captura de pantalla 2017-10-26 a las 22.54.13Captura de pantalla 2017-10-26 a las 22.54.40Captura de pantalla 2017-10-26 a las 22.54.59


Lists •…•

--Originally published at ordinary & extraordinary

What this program does is to ask the user for 10 numbers and then the program calculate de standard deviation of them. What is the standard deviation? Well, the standard deviation is the square root of the variance. And what is the variance? Is defined as the average of the squared differences from the Mean. I created a function that calculates it, first it calculates the average of the numbers that will be the Mean, after that the program obtain the difference between the Mean minus each number and square it. And that is the variance, so to obtain the deviation just calculate the square root of the result of the variance. #WSQ7 #arrays #creatingfunctions #callingfunctions Captura de pantalla 2017-10-26 a las 21.58.38Captura de pantalla 2017-10-26 a las 21.59.03Captura de pantalla 2017-10-26 a las 21.59.25Captura de pantalla 2017-10-26 a las 21.59.51