Breaking News

The Basic Concept of C++

In this post there are some important concepts we have to understand before we proceed.
Any Programming Language has a something called Syntax, these are the rules that guide you to do something, if you know this means you know the Programming and vice versa is true. Anything that you are going to read in this post is a part of Syntax so if you will use it against then you not good in Programming.
First we have to look on What is variable name in Programming?
  • Variable: Is a name, character, word or combination of characters that can be used to store data (value) in a Computer memory. Example: (Name) Diana can be a variable, (Word) Hello can be a variable, (Character) B can be a variable, (combination of characters) xyz can be a variable.
Note: If a name can be a variable, what about 50Cent, can be a variable? The answer is NO. Why? This is because of the following reasons. And here we are starting to look the Syntax of creating variables.
There are 5 rules that you have to understand well as you understand your name.
  1. Variable name can't start with number. From this rule we get the logic of why the name 50Cent can't be used as a variable name, because the name itself start with number 50.
  2. Variable name can start with A-Z, a-z or underscore ( _ ). From this rule we get to know that, if variable can't start with number so can start with either A-Z, a-z or _. Example, Diana is a valid variable and from A-Z we picked a letter D and start with it to create a full name Diana. Also diana is a valid variable and from a-z we picked a letter d and start with it to create full name diana (small letter). And also _Diana or _diana is a valid variable name since it start with _.
  3. Variable name can't contain space in between. Example: Diana Fred can't be a variable name because there is a space between Diana and Fred.
  4. Use underscore to represent space. Example: Diana_Fred can be a variable name because it contains underscore ( _ ) to represent space.
  5. Don't use keyword as a variable name. Keywords are the words that are reserved in a certain Programming Language to perform a specific task. In C++ keywords are int, while, do, for, if, case, e.t.c. There are a lot of keywords where each one has a specific task, those can't be used as a variable name. When we start practical, you'll get to know many of them with their functions.
We are done...!!

Please comment and share with your friends. Don't miss the following post where we will continue to learn the other basic concepts of C++ and that will also be a good foundation in your journey.

Thank you for reading....!!!

No comments