Mastery 6

--Originally published at Programing 101

The difficult part : i forgot everything about factorial numbers so a found a video in youtube explaining what was that and then check it in the cplusplus page about factorial, i found it and i did my own, obviously my firs try didn’t work but it was because i didn’t declare my variables

 the easy part : checking the programing of my friends and ones in the internet

what i learn:

  • how to do a factorial again
  • how to put that factorial to work in my program

661

>>c++ page command<<<

>>Factorial numbers<<


WSQ06 “Factorial Calculator”

--Originally published at blog de Horacio

What to do:

Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).

After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).

progress:

primero tenemos que definir las variables de tipo int.

después tenemos que hacer un ciclo en el cual el numero factorial salga.

El factorial de un entero positivo n, el factorial de n o n factorial se define en principio como el producto de todos los números enteros positivos desde 1 (es decir, los números naturales) hasta n. Por ejemplo,

5!=1×2×3×4×5=120. 

La operación de factorial aparece en muchas áreas de las matemáticas, particularmente en combinatoria y análisis matemático. De manera fundamental el factorial de n representa el número de formas distintas de ordenar n objetos distintos (elementos sin repetición). Este hecho ha sido conocido desde hace varios siglos, en el siglo XII por los estudiosos hindúes.

La definición de la función factorial también se puede extender a números no naturales manteniendo sus propiedades fundamentales, pero se requieren matemáticas avanzadas, particularmente del análisis matemático.

La notación matemática actual n! fue usada por primera vez en 18081 por Christian Kramp (1760–1826), un matemático francés que trabajó en especial sobre los factoriales toda su vida.

Github source:

 

 


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.

Progress:

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.

CODE:

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!!!!!"

Cout << “List” << endl; // WSQ07

--Originally published at Alvaro_246

“List”

En esta tarea hice un programa que le pidiera al usuario 10 números y realizara las siguientes funciones

10

Este programa tiene 3 funciones:

1- La “sumatoria”de los números:

float Sumatoria(float a, float b, float c, float d, float e, float f, float g, float h, float i, float j){
float Rsum;
Rsum = (a + b + c + d + e + f + g + h + i + j);
return Rsum; 

2- El “promedio “de los 10 números:

float Promedio(float a, float b, float c, float d, float e, float f, float g, float h, float i, float j){
float Rprom;
Rprom = ((a + b + c + d + e + f + g + h + i + j)/10);
return Rprom;

3- Por ultimo y más complicado la “Desviación estándar” entre los 10 números:

float Varianza(float a, float b, float c, float d, float e, float f, float g, float h, float i, float j){
float Rvari, Pizza, Total, DesvSTD;
Total = (a + b + c + d + e + f + g + h + i + j);
Pizza = Total/10;
Rvari = pow(a-Pizza,2)+pow(b-Pizza,2)+pow(c-Pizza,2)+pow(d-Pizza,2)+pow(e-Pizza,2)+pow(f-Pizza,2)+pow(g-Pizza,2)+pow(h-Pizza,2)+pow(i-Pizza,2)+pow(j-Pizza,2);
DesvSTD = sqrt(Rvari/10);
return DesvSTD;

Código y Resultados:

Codigo LISTResultados1Resultados 2


cout<<“Fibonacci number <<endl;

--Originally published at Alvaro_246

“Quiz Week 08”

En el Quiz de la semana numero 8, Trabajamos con la sucesión de Fibonacci e hicimos un programa que nos mostrara la seria de Fiboncci hasta un numero determinado que el usuario ingrese. Para ello hice una funcion llamada fibonacci la cual recibe un numero entero que va a ser igual al limite de la serie. void fibonacci(int numero){}. Dentro de la función puse un “while” con la condición de que el numero que ingrese el usuario no puede ser <0. La funcion fibonacci contiene la siguiente formula para la serie de Fibonacci :

while(Base <=numero){
cout << Base << “,” ;
x1 = x2;
x2 = Base;
Base = x1 + x2;
}

Fibonacci

Código y Resultados:

2017-03-12 (5)2017-03-12 (6)


cout<< “Starting Again” <<endl;

--Originally published at Alvaro_246

“ON TO FUNTIONS”

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.

2017-02-27-1


Quiz Week 8

--Originally published at blog de Horacio

  • Write a function that calculates returns the “nth” Fibonacci number where we define a function over the Fibonacci numbers mapping the naturals (starting with zero) to the Fibonacci series. So fibonacci(0) returns 0, fibonacci(1) returns 1, fibonacci(2) returns 1 and so on. Note that we are using the modern definition where the sequence starts with zero. You should try to implement this with two solutions: one with a loop and one with recursion. Which do you think is “better”, which looks more “elegant”, which is more “efficient”?
  • captura-de-pantalla-2017-03-06-a-las-08-44-58
  • FIBONACCI SERIES :En matemática, la sucesión de Fibonacci (a veces llamada erróneamente serie de Fibonacci) es la siguiente sucesión infinita de números naturales:
    0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597…{\textstyle 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597\ldots \,}

     

    La espiral de Fibonacci: una aproximación de la espiral áurea generada dibujando arcos circulares conectando las esquinas opuestas de los cuadrados ajustados a los valores de la sucesión;1adosando sucesivamente cuadrados de lado 0, 1, 1, 2, 3, 5, 8, 13, 21 y 34.

    La sucesión comienza con los números 0 y 1,2 y a partir de estos, «cada término es la suma de los dos anteriores», es la relación de recurrencia que la define.

    A los elementos de esta sucesión se les llama números de Fibonacci. Esta sucesión fue descrita en Europa por Leonardo de Pisa, matemático italiano del siglo XIII también conocido como Fibonacci. Tiene numerosas aplicaciones en ciencias de la computaciónmatemática y teoría de juegos. También aparece en configuraciones biológicas, como por ejemplo en las ramas de los árboles, en la disposición de las hojas en el tallo, en las flores de alcachofas y girasoles, en las inflorescencias del brécol romanesco y en la configuración de las piñas de las coníferas. De igual manera, se encuentra en la estructura espiral del caparazón de algunos moluscos, como el nautilus.

    CODE:

  • #include<stdio.
    Continue reading "Quiz Week 8"

Quiz6

--Originally published at Programing 101

the difficult part: well this quiz was a big one because we need to program not 1 ,not 2 but 4 programs and all of them were different for each other it was like a exam.

so in the first of them : 1

I find difficult the part that i didn’t know what type of program i was making so when i taste it i find out what was all about it, it was a demonstration about how the number changes using different declarations.

the easy part:  all the programing was in the instruction so i dint have to find them all

the difficult part on the second of them :

2

it was easy but the only thing that i had problem was the results because it didn’t match with other answers that my schoolmates get so i check and find out that my problems was that i didn’t declare a or b

the difficult part on the fourth: i get annoyed in this one because i used a lot of if to get the results right

4

i get a lot of bad answers right because i didn’t declare some variables and i didn’t put the } in the end of some ifs and all caught me in the terminal but at the end i manage to solve it

the easy part:

the most easy program that i did was the third one because basically it was a copy paste program

3

what i learned: i didn’t learn anything but i reinforce my knowledge about all the course


about C++

--Originally published at blog de Horacio

Qué es un Lenguaje de Programación

Antes de hablar de C++, es necesario explicar que un lenguaje de programación es una herramienta que nos permite comunicarnos e instruir a la computadora para que realice una tarea específica. Cada lenguaje de programación posee una sintaxis y un léxico particular, es decir, forma de escribirse que es diferente en cada uno por la forma que fue creado y por la forma que trabaja su compilador para revisar, acomodar y reservar el mismo programa en memoria.

Existen muchos lenguajes de programación de entre los que se destacan los siguientes:

  1. c
  2. c++
  3. basic
  4. Ada
  5. Java
  6. Pascal
  7. Python
  8. Fortan
  9. Smalltalk

Contador.cpp // cout<< “The + of the # in the range is : “<< endl; Error … !!

--Originally published at Alvaro_246

SUM OF NUMBERS

En este programa utilice un contador “do” para poder lograr el objetivo, que es sumar los números que se encuentren en un determinado rango, independientemente de los números que ingrese el usuario.

2017-02-13-6

2017-02-13-3 2017-02-13-1 2017-02-13-2

 

CODIGO:

#include <iostream>
using namespace std;

int main()
{
string Respuesta;
int num1, num2, con=0;
cout <<“This program calculate de sum of all numbers in specific range”<< endl;
cout <<“You want to try ….?” <<endl;
cin>> Respuesta;
if (Respuesta==”Yes”){

cout <<“Give me the lower number”<< endl;
cin >> num1;
cout <<“Give me the upper number”<<endl;
cin >> num2;
int con2=num1;
do{
con=con+con2;
con2 ++;
}while (con2<=num2);
cout << ” Sum is:” << con <<endl;}
return 0;
} //Alvaro_246