Ex2+T1+Question+1

· What is a variable, why do we need them, how do we use them and for what? A variable is a l code (it can be numerical or a letter, rules: no use of already done statements, and no spaces) that stores a value (for example: a = 5), in its memory. They are also call memory boxes. We need variables to save values, because if we don't have them for example; the program won´t be able to storage an x value after another order was introduce. In Microsoft Visual Studio, we us them at the top of the program, beneath the above written:

public partial class Form1 : Form { int a; and we determine its data type by writting int, float, etc. before them.As is is show in the example, where the variable has an integer value.

We use variables to know that behind that "a" letter (in the case of the example), an int, float, etc. lies on it, rather than writting all the numbers, characters, texts and bools on the program. It makes programming easier as the computer know that there is something stored under a small code, so it's faster, easier, and also you can avoid using the whole number to do operations, you can simply use a whole bunch of variables to do the programming.

· What is casting and why is it used?

Casting is a way of changing from one data type to another. It is used when programmers want to change from one data type to another, for example, from float to int. It is used to make our llives easier by changing automatically 5.6 to 6, for example, rather than changing manually all the number results, or all the instructions from each programming code. It can also change numerical forms to letter forms and viceversa. For example, casting would be useful in a program that determines if you passed of not. Your grade could be 6. 5 and the computer might round it up to 7, as it's numbers, you can't determine if someone passed or not. You can say that higher than 6 passes, so the message box would say you passed, but for that, you had to turn from decimal to integer numbers and from there, to a text.

· What is an if statement, for what do we use it and how does it works. IF statements are used when you want to decide on different situation and if given, the program has to react differently, for example, we can have that if a>b, then the text turns pink, and if a<b, then the text turns blue. That way you can have different orders to do according to each situation that can be presented in the future.

· What is the difference between an If statement and an If/Else statement As stated above IF statements can be used on an unlimited number of times, you can have as many IFs as you like, and normally for humans it's easier to understand a whole bunch of IFs than the next option, which is to put ELSE. ELSE is a little similar to the IF, only that ELSE indicates if the IF condition wasn't met, you have to do........ For the computer it's easier to have a lot of elses, as it works like this "hum, this isn't done, so I go to the ELSE condition, which shuld have the condition I'm having here". This is faster for a computer (although it's a little harder for humans), as it descart inmediately the option that wasn't met and goes directly to the next one. Of course, this "fastness" is relative, as we may not percieve it, as it's a matter of miliseconds, unperceptible to humans. An example of a IF/ELSE statement is: if (textBox1.TextLength > 0) { a = Int32 .Parse(textBox1.Text); textBox1.Text = "" ; c = '/' ; } else { MessageBox .Show( "You have to write a number" ); } Which is indicating that if the text box length is bigger than zero, a division must be done, otherwise, a message box must pop up, with the message "You have to write a numer" on it, therefore, indicating the user that he/she has done something wrong and has to correct the mistake in order for the program to work. .

· How do we use a MessageBox The message box is used to show a message, either a text or a number type one, that appears in the screen of Microsoft Visual Studio. We use a message box to announce our users something, for example, if there's an error with the way they typed the information, or if we want to publish results that way (ex. "Congratulations, you have won one million dollars!!!"). To program a message box, you have to open visual studio and type MessageBox .Show( "You have to write a number" ); after typing an action.

You have to be careful, because message box don't need a "=" sign, and they ALWAYS need to have a parenthesis that closes. You may put whatever message you want to show between quotes and as always, don't forget the dot and comma at the end. Message boxes are useful expecially for reminding people small things, such as, when they want to navigate out of a page, ask them whereas they want the computer to save the changes done to the program or the tabs that they were using. It can also ask you for permission to remmember your passwords for now onwards, or if you want an update on your program. It's common to find two options on the message boxes: "accept" and "cancel". Other common message boxes types are "Remind me later" or "Save".

· What are the operators, which operators can we use and for what? Operators are signs like +, -, *, /, % that we use to make an operation between two variables. We can use algebraic operators such as + (to add), - (to substract), * (to multiply), / (to divide), % (to show the remains of a division), = (to show us the final result between two variables and one operator). We can also use operators of comparison such as <, >, >=, <=, or ==. This operators are going to compare 2 numbers and say which one is bigger than or smaller than the other (<, >), they can also tell you which one is bigger than or equal to, smaller than or equal to the other (>=, <=), or they are going to simply show if both numbers are the same (==). Other operators that we have are ++ and -- which are going to simply add (++) or substract (--) one number to the number written in the textbook. We have addition operators that are +=, -=, *=, /= and %=. This are going to be used a little differently than the first operators we had explained. With this operators, we can have an already saved value, for example, in **a**, and to have that variable modified again and again without changing it, for example, we could have: a+= a +b, which means that now on **a** we will have the new variable saved that would be the addition of a + b (b is another variable). And so on, with -= we would have a sustration of two variables saved in in a "new" a and so on and so forth with each of the signs we used.