Author Archives: Aurora Alvarado

#Mastery24 Creation/use of arrays

An array is a consecutive group of memory locations that all have the same name and the same type. To refer to a particular location or element in the array, we specify the name if the array and the position number of the particular element in the array. The position number contained within square brackets is more formally called a subscript or index, this number specifies the number of elements from the beginning of the array. This subscript must be an interger expresion. 

Arrays occupy space in memory. The programmer specifies the type of each element and the number of elements required by an array:

type  arrayName [ arraySizeand the compiler reserves the appropiate amount  of memory.

The elements of an array can also be inicialized in the array declaration by following the declaration with an equals sigh and comma-separated list enclosed in braces of inicializers. 

The picture shows an example that I used in WSQ10 of an array.

To see the program you can check my Github: https://github.com/Auralgo/-TC1017/blob/master/wsq10.cpp

 

From “C++ How to program” by Deitel.

#Mastery21 Use of recursion

Recursive problem-solving approaches have a number of elements in commmon. A recursive function is called to solve a problem. The function actually knows how to solve only the simplest case. If the function is called with a base case, the function simply returns a result. If the function is called with a more complex problem, the function divides divides the problem into two comceptual pieces- a piece that the function knows how to do and a piece that the function doesn’t know how to do. To make recursion feasible, the latter piece must resemble the original problem, but be a sightly simpler or smaller version of the original problem. The recursion step often includes the keyword return, because its result will be combined with the portion of the problem the function knew how to solve to form a result.

An example of recursion is the Fibonacci serie shown in the picture.

You can check this code on my Github account: https://github.com/Auralgo/-TC1017/blob/master/fibo.cpp

 

From “C++ How to program” by Deitel

#Mastery20 Use of loops with for

The for repetition structure handles all the details of counter-controlled repetition. The picture shows an example.

The general format of the for structure is

for ( initialization statement; loop continuation condition; increment )

When the for structure begins executing, the control variable i is declared and inicialized to 0. Then, the loop-continuation i <= size is checked. The inicial value of is 0, so the condition is satisfied and the body statement prints the value of i, namely 0. Then the expresion i++  increments control variable i and the loop begins again with the loop-continuation test. The control variable is now equal to 1, so the final value is not exceeded and the program performs the body statement again. This process continues until the control variable i is incremented upper than the value size given by the user- this causes the loop-continuation test to fail and repetition to terminate. The program continues by performing the first statement after the for structure.

You can check my Github repository -TC1017 to see more code: https://github.com/Auralgo/-TC1017

 

From: “C++ How to program” by Deitel.

#Mastery11 Calling C++ Functions

We write functions to define specific tasks that could be used at many points in a program. 

A function is invoked (made to perform its designated task) by a FUNCTION CALL

The function call specifies the function name and provides information (as arguments) that the called function need to do its job. 

Math library functions allow the programmer to perform certain common mathematical calculations.

Functions normally are called by writing the name of the function, followed by a left parenthesis, followed by the argument (or a cooma-separated list of arguments) of the function, followed by a right parenthesis, as shown in the red circle. To see the complete program (WSQ08) you can check it on my Github account: https://github.com/Auralgo/-TC1017/blob/master/wsq08.cpp

 

From: “C++ How to program” by Deitel.

#Mastery04 Check out my Github page to see -TC1017 repository https://github.com/Auralgo #TC1017

Check out my Github page to see -TC1017 repository https://github.com/Auralgo

#WSQ12 Greatest Common Divisor. Check my code on Github https://github.com/Auralgo/-TC1017/blob/master/wsq12.cpp Here’s a link where I found a code //http://fahad-cprogramming.blogspot.mx/2013/11/find-greatest-common-divisor-gcd-of-two.html, i just write it into function.

Greatest Common Divisor. Check my code on Github https://github.com/Auralgo/-TC1017/blob/master/wsq12.cpp Here's a link where I found a code //http://fahad-cprogramming.blogspot.mx/2013/11/find-greatest-common-divisor-gcd-of-two.html, i just write it into function.

#WSQ10 Lists Check my code on Github https://github.com/Auralgo/-TC1017/blob/master/wsq10.cpp I had to review WSQ08 to remmember the use of functions, and look in wikipedia for

Lists Check my code on Github https://github.com/Auralgo/-TC1017/blob/master/wsq10.cpp
I had to review WSQ08 to remmember the use of functions, and look in wikipedia for what is standart deviation

#WSQ09 Factorial Check my code on Github https://github.com/Auralgo/-TC1017/blob/master/wsq09.cpp I got information from “C++ how to program” Deitel #TC1017

Factorial Check my code on Github https://github.com/Auralgo/-TC1017/blob/master/wsq09.cpp
I got information from "C++ how to program" Deitel

Quiz #7 on Github https://github.com/Auralgo/-TC1017/blob/master/q1quiz7.cpp #TC1017

#Mastery12

Creating C++ functions

In C++, a function is a group of statements that is given a name, and which can be called from some point of the program. You need a type of the value returned by the function,  a identifier by which the function can be called, and parameters. Each parameter consists of a type followed by an identifier, with each parameter being separated from the next by a comma. Each parameter looks very much like a regular variable declaration and in fact acts within the function as a regular variable which is local to the function. The purpose of parameters is to allow passing arguments to the function from the location where it is called from.

This is one example I did for WSQ08