Chars of a string ∑

--Originally published at ordinary & extraordinary

At the beginning what this program does was to ask the user to introduce a string, and when the user clicked enter, the program counted how many o’s were in the string. Then a changed it a little bit, to make it more interesting. What this second program does is to ask the users to introduce a string too, but then ask the users to enter the letter they want to find, so this new program will tell you how many letters (the one that the users decided) are in the string.  #strings #arrays #TC1017 #quizweek10 Captura de pantalla 2017-10-14 a las 13.06.12Captura de pantalla 2017-10-14 a las 13.07.16Captura de pantalla 2017-10-14 a las 13.07.51Captura de pantalla 2017-10-14 a las 13.21.20


Why and how did I create a blog?

--Originally published at ordinary & extraordinary

Before this class I had never had a blog, it was an interesting idea but I had never created one. Ken asked us to create a blog and to post on it our work and some other things if we want, so that is the reason why I created my blog. I have many things planned to post on it beside my codes and programs, so be prepared for new things. I created my blog in wordpress ( https://wordpress.com/ ), it was really simple because the same page tells you every step you have to follow; just think in an original name. J Here are some images of the steps you have to follow to create your own blog. Having a blog is a good idea because you can express what you like, what you do, what you would like to do, and anything you want. You can be yourself and say all the things you have reserved for your own. #blog #creatingablog

Haga click para ver el pase de diapositivas.

 


Factorial #!

--Originally published at ordinary & extraordinary

As there are many ways to solve a problem there are many ways to write a program. For this one a decided to do all the process inside the program, it means that I didn’t use any function. What I did first was to ask the user for a number, then if the number was 0 it printed 1, but if the number was not 0, the program made the calculation for the factorial of that number. To make that calculation I create four different variables, one for the value that the user will provide, one more for a variable that will contain the factorial, another one for the variable that will be changing its value to enter or not to the loop, and the last one to save a value that will tell us to repeat or not the process with a new number, depending on the answer that the user give to us. To explain it better, and not get confused with a lot of words I added below some images of my code and how it works. #WSQ06 #loop #dowhile #conditionif #elseCaptura de pantalla 2017-09-14 a las 23.16.14Captura de pantalla 2017-09-14 a las 23.14.52Captura de pantalla 2017-09-14 a las 23.15.05Captura de pantalla 2017-09-14 a las 23.15.24


On to functions ÷+-

--Originally published at ordinary & extraordinary

This program was about to create our own functions. I reuse a previous program that I have done before, that program is “Fun with numbers”, I posted it too. So what I have to do was to create my own functions to calculate the sum, the difference, the product, the integer based division and the remainder of integer division of the two numbers instead of writing the calculation in the program. To create a function just declare what kind of values it will store (int, string, float) followed by its name int sum then in parentheses write the list of parameters that specifies what information you have to provide in order to use the new function int sum (int x, int y), after that just add a pair of square brackets and inside them write what you want your function to do. When you have created all the functions you need, is time to call them in your program. To call them you just have to create a new variable and inside it add the function, if everything is good it must run without any problem. #WSQ05 #newfunctions #creatingfunctionsCaptura de pantalla 2017-09-14 a las 22.20.16Captura de pantalla 2017-09-14 a las 22.20.26Captura de pantalla 2017-09-14 a las 22.21.56Captura de pantalla 2017-09-14 a las 22.21.10


Run a file from command line (terminal)

--Originally published at ordinary & extraordinary

When I started to program in high school I did it in a program where I didn’t have to compile my program to run it, but now where I program I have to compile my program to run it, so I need a terminal. My computer has a terminal installed so I didn’t have to download anything. I didn’t know how to compile a program, but it was easy to learn. First you have to change the direction to the place where your program is, then if the directory is correct you have to write g++ followed by the name of your program (g++ name.cpp), after that if your program does not have any syntax error the next step is to execute it writing (./a.out), but if you have any syntax error, look what your error is fix it and try to run it again until you can run it; to identify a syntax error just take a look to the line where the terminal indicates the error. And that’s it. #terminal 

Haga click para ver el pase de diapositivas.

 


Atom (code editor) 

--Originally published at ordinary & extraordinary

Before I started to program in my computer I needed a code editor, the code editor that I use to program in my computer is Atom, the one that Ken recommended us to install. What I did to install it was something really easy; I just searched it on the Internet and downloaded it. Here is the link: https://atom.io/ . Here is where everything started. At the time I installed it I started to program. It was easy to learn how to use Atom, because at the moment you open Atom automatically it teaches you the easy way to use it. The hard part was to start writing because I knew nothing about C++. Now everything is different because I know how to program in C++, I have been learning with every assignment. One of the reasons I like Atom is that you can write in many languages, and it is very easy to use. I recommend you to use Atom, you would love it. ♥ #atom #codeeditor

Haga click para ver el pase de diapositivas.

An interesting sum +

--Originally published at ordinary & extraordinary

Well I have not told you this before, but every time you want to write a program you have to analyze what you want your program to do. It is just like in daily life, when you want to solve a problem; the first thing you have to do is to identify the problem. So what I had to do in this program was to ask the user for two numbers and do the sum from the lower number to the upper number including both numbers. First I created an integer variable for each number, and then I asked the user to introduce a number for each variable, after that, I wrote a condition and a loop, in the condition I just ask if the lower number is equal to the upper number. If both numbers are different the program will sum from the lower to the upper number with a loop and then will show on screen the result of the sum.  #WSQ04  #loop #types #nestedconditionalsCaptura de pantalla 2017-09-12 a las 17.54.36Captura de pantalla 2017-09-12 a las 17.54.45Captura de pantalla 2017-09-12 a las 17.55.33Captura de pantalla 2017-09-12 a las 17.56.01


Pick a number ∞

--Originally published at ordinary & extraordinary

First when I saw what I have to do in this program I was a little confused, because I have never written a code that use the function random, so I didn’t know how to make the program to pick a random number and make the user guess it. So I investigated on the Internet and I found the function I needed to make that, then I wrote my code and it is supposed to be done but when I ran it and the user tried to guess the number it was always the same number, so in the next class I asked Ken why that was happening, and he told the there was something missing in my program, I need a function to initiate the random function, what I have done was to put a limit to the random function but I never called it so there wasn’t a random number. When I fix it I tried to run it and it ran successfully. To fix that little logical error I just call the function in my program. When someone runs this program it will ask the user to write a number between 1 and 100, then the program will tell you if you are right, if the number you have to guess is lower than the one you wrote or if the number you have to guess is bigger than the one you wrote, when you guess the secret number the programs told you in how many chances you got it. In the pic below you can see how this program works. #WSQ03 #libraries  #whileCaptura de pantalla 2017-09-12 a las 10.34.27Captura de pantalla 2017-09-12 a las 10.43.32Captura de pantalla 2017-09-12 a las 10.36.11Captura de pantalla 2017-09-12 a las 10.37.05Captura de pantalla 2017-09-12 a las 10.49.17


Temperature

--Originally published at ordinary & extraordinary

What this program does is to convert temperature in Fahrenheit to Celsius with the formula, that someone has done before. First of all I wrote the first two lines that I always have to write in all programs. Then I created two integer variables, one to save the value of the temperature in Fahrenheit and the other one to save the temperature in Celsius. After that I asked the user to introduce the temperature in Fahrenheit and I saved that value in the variable named fahrenheit. Having that value what I did next was to write the formula to convert from Fahrenheit to Celsius and saved that value in the variable named celsius; finally I showed those values on screen. And to make this program a little more interesting it also shows on screen if water boils at that temperature or not; to do that the only thing that a have to do was to use the conditional if. To write this code and make this program run I didn’t have to investigate or ask anything, I learned enough to this program with the ones I did before. #WSQ02   #conditionalif #elsewithaconditionalifCaptura de pantalla 2017-09-12 a las 8.34.36Captura de pantalla 2017-09-12 a las 8.35.17Captura de pantalla 2017-09-12 a las 8.34.20


Fun with numbers

--Originally published at ordinary & extraordinary

How does this program work? Well, first of all I had to write a code that at the time I run it the user can introduce two numbers. After the user introduce the numbers, the program makes some calculations and shows you the sum, the difference, the product, the integer based division and the remainder of the integer division of those two numbers. This activity was easy to me, I just had to investigate how to create variables and which command was the one I had to use to let the user introduce information in C++, so I read some more chapters of the book. I enjoy programming and creating codes, I know that those I’ve done are really simple but later I’m going to write more complex codes to more complex programs, this is just the beginning.    #numbers #WSQ01 Captura de pantalla 2017-08-25 a las 11.00.22Captura de pantalla 2017-08-25 a las 11.00.49Captura de pantalla 2017-08-25 a las 11.01.04