Ex1+T1+Question+1

· What is a variable, why do we need them, how do we use them and for what?

A variable is the type of instruction you are giving to the program. For example variables can be boolean, and in this case, the variable will state if a value is true or false. Variables have like categories in which instructions have to be very specific and if there is a mistake it won't work. Every variable needs a value and a name, the name can't start with signs like: !"#$%&/=?¡, etc. without a name or a value the variable does not make any sense.

· What is casting and why is it used?

Casting is a way in which you can write your variables and if they're not correctly written the program will change them or modify them so they can work.

· What is an if statement, for what do we use it and how does it works.

An if statement is an instruction to make conditions and respective outcomes inside your program. It is used to give specific instructions of what needs to happen if the values of a certain condition is met (for example if a variable is bigger, smaller or equal to another given value then a mesaage box will display something). By using if statements you tell the program to do something specific in case of other thing. It works by writing first if and then the condition in brakets. Then in "{}" signs you enclose the instructions of what should happen if the previous condition is met. The code should look like this:

if (x<=0) { label2.Text = "Perdiste"; }

· What is the difference between an If statement and an If/Else statement

An If/Else statement has instructions on what to do if the conditions set by the If statement aren't met, in the form of an Esle statement. What this means is that all possible actions are considered because they will either meet the first conditions (If) or not (Else). On the other hand, the If statement only sets one condition and its corresponding outcome. If that condition is not met then the program will do nothing. This means that not all actions will have an outcome, only those that meet the conditions of the If statement.

· How do we use a MessageBox

A MessageBox is used to give a message to the user after doing something. For example, if I want the user to know that my favorite color is pink after clicking a button, my code should look like this:

namespace qs1 { public partial class Form1 : Form { public Form1 { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show ("My fave colour its pink"); } } }

To do this, I first opened Microsoft Visual Studio, then I created a button inside Form 1, then I clicked twice in the button and wrote the code: "MessageBox.Show ("My fave colour its pink"); This is because the MessageBox is what we want to use, the .Show is to tell the program what to do with the MessageBox (that is to show a text), the text we want the user to know has to be inside parenthesis and quoted. Don't forget to use ; after each instruction. When you run the application and click the button the text "My fave colour its pink" will appear.

· What are the operators, which operators can we use and for what?

Operators are the instructions related to changing values inside the program. Some operators are +, -, *, /, %, <, >, ==, <=, >=, ++, --.