Sunday, 10 March 2013

Week 6 day 1

Today I learned about global variables. There are variables that can be called from any function in the program. For example;

#include <iostream>
using namespace std;
int myInt = 6; //This is your global variable

int main()
{
    cout << myInt;
    return 0;
}
that is a basic global variable program. Using global variables are very dangerous though, as they are shared data that any other function can change the data to. Which in turn creates a bug that is very challenging to find.

Friday, 8 March 2013

Week 5 day 4


Today I learned more about the function controlling for C++. It was quite boring though, functions can be used to do almost anything that you can tell or think of. You can make a function for sending a signal app-on an error, or make it do something when something else is done. This is good if you have an error that happens and you want it to return a lone of code when the error occurs in the program. Or if you want it to send you a message when it has completed a task.

Thursday, 7 March 2013

week 5 day 3

Today, I learned more about functions, I learned about how they can be used to add or subtract and multiply or divide numbers you enter into it. using a lone of code like this:
int addFunction (int a, int b)
{
      x = a+b;
      return (a + b)
}
this would add the numbers together and then assign them to the letter X, to be called by any function. This is the basics of using math to call something from another function just to add them together.

Week 5 day 2

Today I have downloaded and burned two DVD's: one is a Hirens boot CD, which is used for finding and repairing any problems on a computer as well as recovering files; and Geek squad MRI tools, this is used for diagnosing any problems with components of a computer. These two CD's are very useful for any computer technician as they can find almost any problem on a computer. I have also learned about basic math using C++ for example:

int x;
x = 12(22*4) + 66/100;

which assigned the value of those numbers to the int x. this is useful as everything with computers is done with numbers.

for example if you wanted something (for example a servo motor controlled from a computer) if you wanted it to go to a specific position you would have to write a code to make it go to the specific number from the position it is at.

Wednesday, 6 March 2013

Week 5 day 1

This day, I learned about how a function is called in C++. when defining a function you use a call function eg;
int myFunction
{
      cout << "This is a function to display this message";
      return 0;
}
That is a basic function, when using C++ you always use the "main" function which is used to call any other functions for example look at the following script;
#include <iostream>
using namespace std;
int myFunction ()
{
cout << "called from myFunction!\n";
return 0;
}
int main ()
{
cout << "Called from main()!";
myFunction();
cout << "Back to main!";
return 0;
}
this prints:
Called from main()!
called from myFunction!
Back to main!

this is the basics of using more than one function with C++. It is also easier for the system to handle if you break up the work into many functions instead of making one do all the work.