Input and Output

--Originally published at TC1017 Solving Problems with Programming

Hi there! Today I have a new topic for you. When you are making a program code everything you write will not appear in the screen unless you print it. This is an output.And the input is something that you will receive from the user of the program.

This is how you use the output or cout

1
2
3
cout << "Output sentence"; // prints Output sentence on screen
cout << 120;               // prints number 120 on screen
cout << x;                 // prints the value of x on screen  

The << operator inserts the data that follows it into the stream that precedes it. In the examples above, it inserted the literal string Output sentence, the number 120, and the value of variable x into the standard output stream cout. Notice that the sentence in the first statement is enclosed in double quotes (") because it is a string literal, while in the last one, x is not. The double quoting is what makes the difference; when the text is enclosed between them, the text is printed literally; when they are not, the text is interpreted as the identifier of a variable, and its value is printed instead. For example, these two sentences have very different results:

1
2
cout << "Hello";  // prints Hello
cout << Hello;    // prints the content of variable Hello 

And this is how you use the input or cin

For formatted input operations, cin is used together with the extraction operator, which is written as >> (i.e., two “greater than” signs). This operator is then followed by the variable where the extracted data is stored. For example:

1
2
int age;
cin >> age;

The first statement declares a variable of type int called

Continue reading "Input and Output"

Basic Types and their use

--Originally published at TC1017 Solving Problems with Programming

Hi there!

I have something new for you to know. There are different data types in which you store a different and specific type of information.

Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t

Each type can store a different amount of data.

Type Typical Bit Width Typical Range
char 1byte -128 to 127 or 0 to 255
unsigned char 1byte 0 to 255
signed char 1byte -128 to 127
int 4bytes -2147483648 to 2147483647
unsigned int 4bytes 0 to 4294967295
signed int 4bytes -2147483648 to 2147483647
short int 2bytes -32768 to 32767
unsigned short int 2bytes 0 to 65,535
signed short int 2bytes -32768 to 32767
long int 8bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
signed long int 8bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
unsigned long int 8bytes 0 to 18,446,744,073,709,551,615
float 4bytes +/- 3.4e +/- 38 (~7 digits)
double 8bytes +/- 1.7e +/- 308 (~15 digits)
long double 8bytes +/- 1.7e +/- 308 (~15 digits)
wchar_t 2 or 4 bytes 1 wide character

You can find more information in here https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm


C++ good style conventions

--Originally published at TC1017 Solving Problems with Programming

Hi there! it´s been a while, but here you can have a list of the “rules” that you should follow to have a good style when you are coding. This exist because you have to make it easier for your reader to understand your code and by following this rules you will achieve that.

3. Names representing types must be in mixed case starting with upper case.
Line, SavingsAccount
Common practice in the C++ development community.
4. Variable names must be in mixed case starting with lower case.
line, savingsAccount
Common practice in the C++ development community. Makes variables easy to distinguish from types, and effectively resolves potential naming collision as in the declaration Line line;
5. Named constants (including enumeration values) must be all uppercase using underscore to separate words.
MAX_ITERATIONS, COLOR_RED, PI
Common practice in the C++ development community. In general, the use of such constants should be minimized. In many cases implementing the value as a method is a better choice:
  int getMaxIterations() // NOT: MAX_ITERATIONS = 25
  {
    return 25;
  }

This form is both easier to read, and it ensures a unified interface towards class values.

6. Names representing methods or functions must be verbs and written in mixed case starting with lower case.
getName(), computeTotalWidth()
Common practice in the C++ development community. This is identical to variable names, but functions in C++ are already distingushable from variables by their specific form.
7. Names representing namespaces should be all lowercase.
model::analyzer, io::iomanager, common::math::geometry
Common practice in the C++ development community.
8. Names representing template types should be a single uppercase letter.
template<class T> … template<class C, class D> …
Common practice in the C++ development community. This makes template names stand out relative to all other names used.
9. Abbreviations and acronyms must not be
Continue reading "C++ good style conventions"

Coding social networks

--Originally published at TC1017 Solving Problems with Programming

Hi there! Today i´m gonna teach you how to start your different social networks that will make it easier your life in coding.

The first one is a tool that you can use for either communicate with other people or publish your code for other people to see. It´s called twitter and you probably already know about it but it is very useful and you should use it.

TWITTER

In this link you will access to the main page of twitter, there you will look for the little button that says register or registrarse and you will click on it. captura-de-pantalla-2017-02-28-a-las-10-05-53

After that you will have to give your full name, an email and a password. Captura de pantalla 2017-02-28 a la(s) 10.23.52.png

Then it will ask another different things but they are not necessary, so basically thats it for twitter.

WORDPRESS

WordPress is the next thing that I will show you how to start. This is a page in which you will be able to make your own blog page, in which you will be able to post your codes and show them to people around in the internet. WordPress is very nice because you can use it for free. Captura de pantalla 2017-02-28 a la(s) 10.47.09.png

You will click on the button that says create a website or crea un sitio web, in there you will be asked a bunch of information and then you will have to choose for a type of account, in which you will have to choose the one that is free, if you don´t want to pay that is.

And that´s it for today blog, use this tools, they are great.


First approach

--Originally published at TC1017 Solving Problems with Programming

This should have been the first post that I posted but I kinda screwed up. Here it is, how to start programming in your mac computer.

First you´ve got to get a compiler, this will compile all the code you make and actually turn it into a program that you will execute.

The compiler that I use and that suits me better is called Atom, this is very good to start. You can download it in here https://atom.iocaptura-de-pantalla-2017-02-23-a-las-17-11-15

The next thing you should do is download homebrew, this thing is the package administrator that you need in your computer. To download it you need to paste the command they give you in your terminal. captura-de-pantalla-2017-02-23-a-las-17-11-39To do that you need to open your terminal first, to do that you need to press the command button and the spacebar at the same time, that will open your spotlight search bar, in which you will simply put terminal and press enter. the next window will appear and there you will paste the command from homebrew. And follow the instructions that there labels. captura-de-pantalla-2017-02-23-a-las-17-12-07

Now you are ready to start coding!! Congratulations and good luck!


How to do comments in your code?

--Originally published at TC1017 Solving Problems with Programming

Hi there, today I have a very simple advice for you to know what you did in a code that have not seen in a long time or for other people that are foreign to you code to know what you did in it.

This simple tool is making comments in you code, specifically telling them what you did and that way it is harder to get lost in the code and how it works.

The process is very simple, the only thing you have to do is put “//” before anything you want to put as a comment, and the program will automatically ignore anything that is beyond that double slash.

captura-de-pantalla-2017-01-31-a-las-10-29-42