Tag Archives: #mastery12

#Mastery11 and #Mastery12 #TC1017

Mastery11 and 12

Calling and Creating Python functions

11 12 1014

#TC1014 #Mastery11 #Mastery12

Funciones en C++

Aqui esta un nuevo tutorial para como poder crear una funcion que hago o desarrollo un codigo especifico del programa y despues como poderla llamar y usarla en el codigo principal.

Aqui esta el link:https://www.youtube.com/watch?v=wu68jwiWRQw&feature=youtu.be

1017

11

12

#Mastery12 Courses with Ken

enjoy this video!

http://youtu.be/S8wYcrytcOY

#Mastery12 Courses with Ken

#Mastery12 Courses with Ken

enjoy this video!

http://youtu.be/S8wYcrytcOY

#Mastery12 Courses with Ken

#mastery12

12  12 1017

I´m goint to teach how to create a function in c++

First of all you have to choose which type of function you want.

Void = to return nothing.

Int = to return a integer number.

double = to return a decimal number.

bool = to return true or false

string = to return letters.

etc etc.

Well now that you know the types of functions you will have to select the  type you want for your variables which are pretty much the same.

Now, the syntax to do a function is:

type nameoffunction(variables, parameters)

{

}

——————————————–

Let´s say, we want to create a function which make the sum of two integer numbers

int sumnum(int x, int y)

{

     int c;

     c = x + y;

     return c;

}

 

Hope you understand how to create a function, it is really easy and don´t be afraid to create them because it will save a lot of coding and your int main() will be a lot shorter.

 

Hope you understand so i can get my two points!

 

Creating C++ functions – Mastery12

*Crear una funcion es facil. El proceso para crear una es el siguiente:

1- Se programa la unción

2- Se define la función

3- Se utiliza la función en el programa principal.

 

*Su estructura es la siguiente:

Creating C++ functions - Mastery12

 

Por ejemplo:

using namespace std;

int factorial(int a){

int cont, act = 1;

for (cont =1; cont

{

fact = fact*cont;

}

return fact;

}

 

int main(){

int num1;

int resultado = factorial (num1);

cout

cin num1;

cout

return 0;

}

 

 

Si tienen dudas pueden consultar el siguiente enlace: http://aprendecpp.com/blog/programacion-en-c-como-crear-funciones-i.html

1017 12

Mastery 12

12 1017

Una función es un conjunto de líneas de código que realizan una tarea específica y puede retornar un valor. Las funciones pueden tomar parámetros que modifiquen su funcionamiento. Las funciones son utilizadas para descomponer grandes problemas en tareas simples y para implementar operaciones que son comúnmente utilizadas durante un programa y de esta manera reducir la cantidad de código.

 

habiendo dicho lo anterior podemos decir que, cuando seamos unos programadores avanzados, usaremos las funciones para acortar nuestras lineas de codigo o, lo que es lo mismo, facilitar nuestro trabajo, ya que, podremos hacer que las lineas de codigo que usaremos más se puedan escribir solo una vez y que, para volverlas utilizar solo debamos de escribir una linea de codigo en lugar de las tantas que usariamos si no tuvieramos las funciones.

 

¿como usar una función?

el primer paso es determminar que tipo de funcion va a ser, que nos va arrojar, podemos usar int, float, bool, o cualquiera que nosotros queramos usar

el segundo paso, es ponerle nombre a la función, este nombre puede ser en realidad el que nosotros queramos, puede ser desde “cuadratica” hasta “perrito” solo que es recomendable darle nombres relacionados con lo que ahce esa función, ya que si le ponemos “perrito” y trata sobre una función, esta puede llegarnos a confundir y cometer errores.

el tercer paso para realizar la funcion es poner entre parentesis, que y cuantas variables van a ser usadas en nuestra funcion, por ejemplo si queremos que sean tres variables enteras (a,b y c) las cuales vamos a necesitar en la realización de nuestra funcion llamada “ejemplo” y arrojara un numero entero, entonces quedaria asi:           int ejemplo (int a, int b, int c)

 

despues de determinar que arrojara, el nombre y las variables de la funcion procederemos a habrir corchetes “{“, escribir lo que queremos que haga esa función y por ultimo, antes de cerrar nuestra funcion tenermos que poner “return” y la variable que queremos que regrese y por ultimo debemos de cerrar corchetes “}”.

Creating and calling functions in C++

In order to creat a function we need to give it a name first and we need to do that before main, like this:

You need to be clear about whay type of function you are creating, in this case is a boolean, and then followed by the instructions that the function will perform in case you call it.

Now, to call a function you need to type in the name of it, followed by the data that the function will use to work, in this case is “input”, but it can be any data you want, as long as it’s the correct type of data that the function is ready to process.

As you can see here I typed in bool and the name of the function is palindrome, that’s how you call it, I hope this comes useful.