Where is my banana?

--Originally published at Adal´s Blog




No soy muy fan de trabajar con string, pero debido a que tengo que saber trabajar con ellas. y que lo veo como un reto personal, es que he decidido hacer las actividades relacionadas con strings, así que comencemos  


Como ya lo habia comnetado antes, no se me da muy bien los strings, por eso acudi al blog de Fabricio y al de María José para tener un poco mas de ayuda



Al final inserte unos caracteres ascii con la palabra banana y una banana debajo que me encontré en Internet, se me hiso que quedaba a la situación, solo que el compilador se volvio loco con unos caracteres y no supo como imprimir algunas lineas ;(

  

Paginas de ayuda:

#WSQ12

--Originally published at OlafGC / Class #TC1017

This is a video that will help you calculate euler’s number, which is an irrational number… I’m having a little trouble with the function because it’s totally ignoring the precision (which is the number that the user gives, but it does calculate euler’s number correctly.

Here is the code:

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

float factorial(int n)
{
if(n==0)
{
return 1;
}
else
{
return n*factorial(n-1);
}
}

float calculate_e(float precision)
{
float e=1;
float previous;
int i=1;

do
{
previous=e;
e=e+1/(factorial(i));
cout<<e<<endl;
i++;
} while(abs (e-previous)>precision);
return e;
}

int main()
{
float precision;
cout<<“How many decimals of accuracy do you want? “;
cin>>precision;
cout<<“The estimation of e with “<<precision<<” decimal points is: “<<calculate_e(precision)<<endl;
return 0;
}


Dovahkiin, Dovahkiin, naal ok zin los vahriin.. (#WSQ09)

--Originally published at Programming Path

The assignment of #WSQ09 was the next one:

So for this assignment I would like to see you create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line

This for sure was a new topic. It was thanks to Ken’s Disciple 01‘s blog that I could understand this task.

First I needed to make a text file (.txt) so I wrote a Skyrim quote. It is from an ancient dragon and I got attached to him because it was the only friendly dragon, but anyway here is the text:

skyrim

Then we had to make the program open the file and count how many characters and lines does it has. Then print it out.

WSQ09

Thanks for reading.

 


Mi propia biblioteca

--Originally published at Adal´s Blog


Las bibliotecas son lugares donde comúnmente podemos encontrar muchos libros, a la par en una librería de progradación podemos encontrar muchas funciones, para después utilizarlas o no, pero saber que están presentes ahi dentro

Al enseñarle Ken el avance del proyecto sugirió que todas las acciones que realiza el robot se podrían agrupar en una función con el nombre de su acción y después hacer la recopilación de funciones en una librería, me pareció muy buna su idea.

En ese momento no sabia como hacer una, solo se que tenia la extensión .h, pero con una rápida consulta a internet vi que era muy fácil hacerlo, solo es programar el nombre de tus funciones y que van a hacer cada una, y en ves de guardarlo con la extensión .cpp lo cambiamos por .h, el archivo resultante lo guardamos en la dirección de las librerías de nuestro compilador y listo, ya tenemos nuestra propia librería, en mi caso Adalll.h

Programacionenc.net

GO Bananas

--Originally published at Programming

The instuction was:

What To Do

Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana”  (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.

kjhgfdsa


Babylonian method

--Originally published at Programming

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before start, I recomend to look at this page, because well i didn’t know what is the babylonian method, so… if you don’t know, look this !

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The instruction was:

What to Do

The function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ10 on your post so our blog hub picks that up.

 

Here is my code:

Babylonian

#WSQ10

 


Lo tienes que hacer

--Originally published at Adal´s Blog

Había estado aplazando el WSQ08 – Yo Soy 196 porque había oído que estaba algo difícil, pero al final ya que lo he hecho, me he dado cuenta que no es tan difícil como dicen, así que comenzamos:

Esta es la actividad:





El proceso para realizar este fue un poco diferente a los otros ya que teníamos que descargar una libreria para poder utilizar numero muy grandes, pero gracias a los vídeos que Ken nos proporciono y la ayuda de Fabricio porfin lo puede hacer :D




Paginas de ayuda:

Lots of Problems (Quiz week 9)

--Originally published at Programming Path

This quiz was veeeery long. There were 10 problems, but we only had to do 8 problems.

1. Escribe el función distancia cual recibe 4 números (x1, y1, x2, y2) cuales representan dos puntos en espacio (x1,y1) y (x2,y2). El método debe regresar la distancia entre los dos puntos. Recuerda que el valor cuadrada del hipotenusa del triangulo es igual que la suma de las cuadradas de los otro dos lados del triangulo (the hypotenuse squared is equal to the sum of the squares of the other two sides).

Quiz9

2. (5 puntos) Escribe un función que se llama triangulo cual recibe un parámetro size y imprime un triangulo derecho como el siguiente. El renglón mas grande debe llevar size numero de “T”. SOLO imprime los “T”s y los endlines. Nota que no hay characteres (espacios) a la derecha de los T’s. Debe usar un ciclo “for” para controlar el repetición.

PQ2

 

3. Escribe la función factorial cual recibe un entero “x” y regresa el valor de x! Recuerda que 0! = 1, 1! = 1, 2! = 2, 3!= 6, 4! = 24, etc. Para los de Python: NO PUEDES usar el factorial como parte del module “math”

PQ3

4. Escribe una función que se llama promedio_lista que recibe un parámetro (una lista (Python) o arreglo/Vector de C++) de valores float y regresa como float el promedio de los números en la lista.

PQ4

5. Escribe una función que se llama smallest_of_four cual recibe cuatro valores float como parametros y regresa el minimo (más pequeño) de los valores. Ojo: puede recibir unos valores iguales.

Click to view slideshow.

6. Escribe una función que se llama fibonacci cual recibe un número n (puedes dar por cuenta que valor mayor o igual que cero) y regresa y valor correspondiente del serie de fibonacci,

PQ6
PQ7.png
PQ10
?
Continue reading "Lots of Problems (Quiz week 9)"

Distance (Quiz week 9)

--Originally published at Programming Path

The assignment of the quiz was to ask for two coordinates and calculate the distance between them. It needed to have floats and a function as well.

This problem was very easy, because in school they made me calculate the distance a lot of times. I only add the math library (<cmath>) because I elevate to the power and resolve a square root.

Here is the code:

Quiz9

Thanks for reading.