Responsive Ad Slot

.

Religion

Coding

Global

Tech

Variables. Data Types.

Posted on Monday, 27 July 2015 with No comments

The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting program just to obtain a simple sentence written on the screen as result. It certainly would have been much faster to type the output sentence by ourselves.

However, programming is not limited only to printing simple texts on the screen. In order to go a little further on and to become able to write programs that perform useful tasks that really save us work we need to introduce the concept of variable.

Let us think that I ask you to retain the number 5 in your mental memory, and then I ask you to memorize also the number 2 at the same time. You have just stored two different values in your memory. Now, if I ask you to add 1 to the first number I said, you should be retaining the numbers 6 (that is 5+1) and 2 in your memory. Values that we could now for example subtract and obtain 4 as result. The whole process that you have just done with your mental memory is a simile of what a computer can do with two variables. The same process can be expressed in C++ with the following instruction set:
a = 5;
b = 2;
a = a + 1;
result = a - b;

Obviously, this is a very simple example since we have only used two small integer values, but consider that your computer can store millions of numbers like these at the same time and conduct sophisticated mathematical operations with them.

Therefore, we can define a variable as a portion of memory to store a determined value.

Each variable needs an identifier that distinguishes it from the others, for example, in the previous code the variable identifiers were a, b and result, but we could have called the variables any names we wanted to invent,as long as they were valid identifiers.

Identifiers

A valid identifier is a sequence of one or more letters, digits or underscore characters (_). Neither spaces nor punctuation marks or symbols can be part of an identifier. Only letters, digits and single underscore characters are valid. In addition, variable identifiers always have to begin with a letter. They can also begin with an underline character (_ ), but in some cases these may be reserved for compiler specific keywords or external identifiers, as well as identifiers containing two successive underscore characters anywhere. In no case they can begin with a digit.

Another rule that you have to consider when inventing your own identifiers is that they cannot match any keyword of the C++ language nor your compiler's specific ones, which are reserved keywords. The standard reserved keywords are:
asm, auto, bool, break, case, catch, char, class, const, const_cast, continue, default, delete,
do, double, dynamic_cast, else, enum, explicit, export, extern, false, float, for, friend, goto,
if, inline, int, long, mutable, namespace, new, operator, private, protected, public, register,
reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template,
this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void,
volatile, wchar_t, while

Additionally, alternative representations for some operators cannot be used as identifiers since they are reserved words under some circumstances:
and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq

Your compiler may also include some additional specific reserved keywords.

Very important: The C++ language is a "case sensitive" language. That means that an identifier written in capital letters is not equivalent to another one with the same name but written in small letters. Thus, for example, the RESULT variable is not the same as the result variable or the Result variable. These are three different variable identifiers.

READ MORE

Lesson 2 : Structure of a program (Part II)

Posted on with No comments
In C++, the separation between statements is specified with an ending semicolon (;) at the end of each one, so the separation in different code lines does not matter at all for this purpose. We can write many statements per line or write a single statement that takes many code lines. The division of code in different lines serves only to make it more legible and schematic for the humans that may read it. Let us add an additional instruction to our first program.

This is input:                                                                      This is output:

// my second program in C++
#include <iostream>                                                           Hello World! I'm a C++ program
using namespace std;
int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
return 0;
}

 In this case, we performed two insertions into cout in two different statements. Once again, the separation in different lines of code has been done just to give greater readability to the program, since main could have been perfectly valid defined this way 
EXAMPLE:
int main () { cout << " Hello World! "; cout << " I'm a C++ program "; return 0; }

We were also free to divide the code into more lines if we considered it more convenient
EXAMPLE:
 int main ()
{
cout <<
"Hello World!";
cout
<< "I'm a C++ program";
return 0;
}
And the result would again have been exactly the same as in the previous examples.
Pre-processor directives (those that begin by #) are out of this general rule since they are not statements. They are lines read and processed by the pre-processor and do not produce any code by themselves. Pre-processor directives must be specified in their own line and do not have to end with a semicolon (;).

Comments

Comments are parts of the source code disregarded by the compiler. They simply do nothing. Their purpose is only
to allow the programmer to insert notes or descriptions embedded within the source code.
C++ supports two ways to insert comments.
Which are:
// line comment
/* block comment */

The first of them, known as line comment, discards everything from where the pair of slash signs (//) is found up
to the end of that same line. The second one, known as block comment, discards everything between the /*
characters and the first appearance of the */ characters, with the possibility of including more than one line.
We are going to add comments to our second program:

This is input:                                                                          This is output:

/* my second program in C++
with more comments */
#include <iostream>                                                                Hello World! I'm a C++ program
using namespace std;
int main ()
{
cout << "Hello World! "; // prints Hello
World!
cout << "I'm a C++ program"; // prints I'm a
C++ program
return 0;
}

If you include comments within the source code of your programs without using the comment characters combinations //, /* or */, the compiler will take them as if they were C++ expressions, most likely causing one or several error messages when you compile it.

Thats it for today we will start a new topic tomorrow anyone that wants to ask any questions or make recommendations please feel free to do so.
             
READ MORE

Rachel Mcadams confirms about Doctor Strange Talks In progress

Posted on Sunday, 26 July 2015 with No comments

Rachel Mcadams says she's up for the part but is skeptical if she will get it or not :

"She is considering playing the female lead in Marvel's "Doctor Strange," which is set to star Benedict Cumberbatch, though she is careful to note, "it's still super-early days, and I don't know where that's gonna go, if it's gonna go anywhere at all." But she's not a "comic book snob."

Doctor Strange starts filming in the fall season. So expect the cast and story to be revealed at Disneys D23 expo.
"Doctor Strange" has a November 4, 2016 release directed by Scott Derrickson starring Benedict Cumberbatch as Stephen Strange and Tilda Swinton as the Ancient One."
READ MORE

Everything to know about Fallout 4

Posted on with No comments
Fallout 4 is one of the most anticipated games for Xbox one, PS4 and PC. So i decided to round up the things we know :

  1. Fallout 4 is set in the Massachusetts area of the East Coast
  2. The possible companion list is rather huge spawning over a dozen at the least including Dogmeat, Mr. Handy, Preston Garvey, and ‘Piper,’ a newly-revealed companion who you can meet in Diamond City.
  3. Mr.Handy is gonna be epic he can actually say your name no matter what it is (TROLLS ARE COMING). Be it anything . Mr.Handy is voiced by Stephen Russel who also voiced Garret in Thief.
  4. Yes you can have sex and make love. Don't even pretend that wasn't on your mind.
  5. There will a lot of creepy crawlies including mutants and robots.
  6. Companions can also be switched. You are only allowed to have companion at a time.
  7. Piper is a woman in Diamond City. Piper is a female depicted in a red leather coat and newsboy hat. There i already told you where you can go for *coughs* you get it right.
  8. Dogmeat the dog is based on a real dog. Yeah i can't get why but he is. You can read the tweet here.
  9. The leveling system has changed considerably. Whenever you level up you get to choose a new perk. The stats are dictated by these 7 attributes Strength, Perception, Endurance, Charisma, Intelligence, Agility, and Luck.
  10. The book and comic covers are much more detailed now. You can zoom on them and actually read them 
  11.  Here are a list of known enemies courtesy of ign:
             Yao Guai
  1. Sentry Bot
  2. Super Mutants
  3. Super Mutant Behemoth
  4. Mirelurk Queen
  5. Synthetics
  6. Radscorpion
  7. Deathclaw
  8. Protectron
  9. Ghouls
  10. Bloodbug
  11. Brotherhood of Steel   
  12. The things that are back again are bloody mess perk, Super Duper Mart, computer hacking, lockpicking, the Fat Man, and Behemoth mutants.
  13. Well have yoi ever hated when someone was being devoured by ghouls and you were having fun watching but the damn game wants you to save him? Well not anymore, Fallout 4 gives you the choice this time around. At least, that's what it looked like in the demo.
READ MORE

WordPress 4.2.3 Fixes Vulnerabilities, Bugs

Posted on Saturday, 25 July 2015 with No comments

The developers of the WordPress content management system (CMS) announced on Thursday the availability of WordPress 4.2.3. This security and maintenance release fixes a couple of vulnerabilities, along with 20 bugs.

One of the security flaws patched with the release of WordPress 4.2.3 is a cross-site scripting (XSS) vulnerability that allows users with Contributor or Author roles to compromise a website. The issue, which affects WordPress 4.2.2 and earlier, was discovered by a member of the WordPress security team, and independently by Jouko Pynnönen of Klikki Oy, who identified several serious vulnerabilities in WordPress in the past. 

WordPress’ announcement doesn’t include any technical details on this vulnerability, but according to managed WordPress hosting provider WP Engine, the issue is related to how shortcodes are used in HTML attributes.
“Essentially, this security issue could enable specially crafted shortcodes to bypass kses protection by tricking it into thinking dangerous parts are part of valid HTML,” WP 

Engine’s Dustin Meza explained. “This vulnerability may allow users without the unfiltered_html capability, but with publishing rights, to run JavaScript code on the front end of the website. This security update ensures all shortcodes inside attributes are evaluated and then run both through kses separately and escaped for use in attributes.”

WordPress 4.2.3 also patches a vulnerability reported by Netanel Rubin of Check Point Software Technologies. The flaw can be exploited by a user with Subscriber permissions to create a draft through the Quick Draft feature.
Users whose installations are not updated automatically are advised to manually install the latest version.

It’s worth noting that WordPress 4.2.1 and WordPress 4.2.2 were released in late April, respectively early May, to address serious XSS vulnerabilities whose details had been made public before patches became available.

**Updated to say that Jouko Pynnönen of Klikki Oy was also credited for reporting the XSS flaw**
READ MORE

Lesson 1:Structure of a program

Posted on with No comments

The best way to start learning a programming language is probably by learning to write a program. Writing a program is the most basic and also crucial part of programming. Why don't we start by learning about the way a program works, it's structure and basics.
Therefore, here is our first program:

This will be the input                                        This will be output 

      #include <iostream>                                                   Hello World!
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}

                                                                                     
The input is the very first program a programmer will ever see and same can be said for the output. Now lets start with the learning. 

#include <iostream>
The "#include" is a pre-processor function that tells the compiler to include the <iostream> library. They are no regular code lines. This specific file "iostream" includes the declarations of the basic standard input-output library in C++. Keep it in mind.

using namespace std;
All the elements of the standard C++ library are declared within what is called a namespace, the
namespace with the name std (standard) . So in order to access its functionality we declare with this expression that we will be using these entities (std) . This line is very frequent in C++ programs that use the standard library. Most programs do use the std library so it is an important point to remember.

int main ()
This line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution, independently of its location within the source code. It does not matter whether there are other functions with other names defined before or after it - the instructions contained within this function's definition will always be the first ones to be executed in any C++ program. For that same reason, it is essential that all C++ programs have a main function.

The word main is followed in the code by a pair of parentheses (()). That is because it is a function
declaration: In C++, what differentiates a function declaration from other types of expressions are these parentheses that follow its name. Optionally, these parentheses may enclose a list of parameters within them.

Right after these parentheses we can find the body of the main function enclosed in braces ({}). What is contained within these braces is what the function does when it is executed.

cout << "Hello World!";
This line is a C++ statement. A statement is a simple or compound expression that can actually produce some effect. In fact, this statement performs the only action that generates a visible effect in our first program.

cout represents the standard output stream in C++, and the meaning of the entire statement is to insert
a sequence of characters (in this case the Hello World sequence of characters) into the standard output stream (which usually is the screen).

cout is declared in the iostream standard file within the std namespace, so that's why we needed to
include that specific file and to declare that we were going to use this specific namespace earlier in our code.

Notice that the statement ends with a semicolon character (;). This character is used to mark the end of the statement and in fact it must be included at the end of all expression statements in all C++ programs (one of the most common syntax errors is indeed to forget to include some semicolon after a statement).

return 0;

The return statement causes the main function to finish. return may be followed by a return code (in our example is followed by the return code 0). A return code of 0 for the main function is generally interpreted as the program worked as expected without any errors during its execution. This is the most usual way to end a C++ console program.

                                            (FIN)

This code could also be written on a single line keep in mind like this :
int main () { cout << "Hello World!"; return 0; }

This would mean exactly the same as the above code and would have same meaning. 
See you on the next lesson and feel free to ask me any questions you might want.

READ MORE

WE START TODAY

Posted on with No comments

From today onwards we will be learning C++.  You may ask any questions regarding C++. We have just taken a start, so there is a lot to come. We are going to learn programming in C++ from scratch. We'll be covering the basics, provide summaries and help in any and every possible way. We hope you become a part of this experience.
READ MORE

Change yourself before changing the world!

Posted on with No comments


Many people want to change the world, don’t they? But, what exactly is the meaning of this word “change”?
Change means to make something different, to cause a transformation or to become different in essence. 
Change is also a process of growing up. 
You want to change the world, but have you ever thought about changing yourself? If not, then you must realise the importance of changing yourself. One must understand that before changing the world, one has to change himself first. 
Remember that “change” is a “process” and not an “event“.

Change is Natural

Change is a very natural process. Everything around us keeps changing. Things change from time to time. But, it doesn’t mean that “time changes everything”. It’s true that things change with time but time does not necessarily change things.

Change is Inevitable

The seasons come and go, so do day and night. Time changes too. Circumstances change. People change. It can’t be winter for an entire year, nor can it be summer for a whole year. It’s impossible. Time is always on the wing. It flies by unnoticed [It changes]. Our surroundings undergo the process of change continuously. Most importantly, we change. You might hear people talking and complaining about someone that changed. We often see such things in our life. “He has changed completely”, “His behavior has changed” etc, etc. It can’t be helped actually. Changing of people is very natural and normal; one cannot remain the same for his whole life. 
Sometimes people are afraid to change. They don’t want to change anything because they do not know how to deal with change. People find themselves in a state of dilemma when it comes to the process of “change”. When things change, they all want it to return to as it was before.
Paulo Coelho said:

“People want to change everything and, at the same time, want it all to remain the same.”

What he said is absolutely true. We want to change the things around us and the world. But sometimes the circumstances are unfavorable. When the circumstances are unfavorable, we need to change ourself.
Changing is not a bad thing. Change yourself, the way you think, the way to react to things. It can really help. But, change in a positive way. In other words, it is a process of improving yourself. Make a list of your bad habits, you flaws etc. Then take steps to rectify them. Know the reason why you want to change. 

Moral Story

Once upon a time there lived a king who ruled a prosperous country. One day, he decided to have a trip to some distant areas of his country. When he came back to his palace after visiting the places, he complained that his feet were throbbing due to pain, because it was the first time he went for such a long trip, and the road he went through was rough and stony. He then ordered his people to cover every road of the entire country with leather.
Definitely, this would need thousands of cows’ skin, and would cost a huge amount of money.
Then one of his wise servants dared himself to tell the king, “Why do you have to spend that unnecessary amount of money? Why don’t you just cut a little piece of leather to cover your feet?”
The king was surprised, but he later agreed to his suggestion, to make a “shoe” for himself.
There is actually a very valuable lesson of life in this moral story: to make this world a happy place to live, you better change yourself – your heart; and not necessarily the world.
READ MORE

Popular Posts