WSQ 05 – On To Functions

--Originally published at MarizProfile

Captura de pantalla 2017-10-09 a la(s) 18.36.47

In this activity I had to use for the first time formulas outside of the main, (not like in the last activities where all the processes took place inside of the main). I used formulas to get the result of several arithmetic operations, like a sum, a subtraction, a multiplication, a division and the remainder of it. To print those results I used a “cout” for each of the operations mentioned, and I returned to call the formula previously written above the main, writing inside the parenthesis the variables used in that formula.

-> For example (division):

int D (int x, int y){

return (x/y);

}

int x, y;

using namespace std;

int main(){

cout<< “The result of the division of those two numbers is:  ” << D(x,y) << endl;

}

 

 


WSQ 04 – Sum of Numbers

--Originally published at MarizProfile

captura-de-pantalla-2017-09-18-a-las-13-21-29.png

In this activity, I had to ask the user for a range of numbers (between 2 values the user would give me), and sum all of the numbers that existed in the range. To do this, I had to use a While loop again. It was very simple, because the 2 independent values were the lower number and the higher number of the range, so that the 2 variables that changed in order to get the sum were “Suma” and “Num”. I had to use a variable “Num” that took the place of the lower number, so that the sum didn’t started by adding numbers from 0, but from the lower number of the range (Num= Num1).


WSQ 03

--Originally published at MarizProfile

Captura de pantalla 2017-09-08 a la(s) 17.48.15

This was the first time I had to use a do while loop, in order to repeat several times some steps in my code. I had to declare a variable x=0, and then I had to create a counter “x=x+1”. Then, at the end of the loop I had to establish a conditional “while”, assigning a value to “x” lower than 4, so that the loop repeated itself 4 times (as long as the user didn’t guess the right Random Number the system would generate each 0 seconds). <– To do this, I looked up for the right tool, that let me command the system to generate a random number each determined amount of time, in this case, every 0 seconds (constantly generating it), using “srand (time(0));”


WSQ01 – Fun with Numbers

--Originally published at MarizProfile

Captura de pantalla 2017-08-25 a la(s) 10.47.17

My second programming activity was also simple, but a little bit longer than the first one, because in this case I had to declare some variables (I could have not declared that quantity of variables and still my program would have run the same way, but it seemed to me that it was easier for me to read it and organize the lines in my code.) Previously had to read some pages in the Book, to understand and know how to declare some variables to make simple arithmetic operations and print in the screen the results of these.


WSQ00

--Originally published at MarizProfile

Captura de pantalla 2017-08-22 a la(s) 08.10.20Captura de pantalla 2017-08-22 a la(s) 08.10.20

This was my first programming activity after checking out the basic Tools I needed to make run my codes. Hello.cpp was a very simple program, in which the screen printed “Hello World”. Before starting to write the code, I checked out a couple of tutorials in Youtube about the “basic structure” of a C++ program, so, with that in mind, I started to look up for Hello World tutorial videos, that showed how to write the code, and explained the way it ran.