Rules of Declaring a Variable.....

      Some Of The Important Rules To Declare VARIABLES In C.........


                    C follows some naming conventions Or you can say rules for naming their Variables. the need for making this information separately is that this is one Of the most avoidable topics while Learning C programming because we Usually don’t care how we name our Variables as it is not the case that Everything is allowed in C programming......
        As we want therefore studying naming Conventions is equally important name Of a variable is composed of letters or Maybe the combination of letters both Uppercase and lowercase and digits rules For naming variables are as follows you Cannot start your variable name with a Digit for example globe is a valid Variable name on the other hand to Globe is invalid even though underscore Counts as a letter but don’t begin Variable names with underscore although You cannot begin with underscore because Huge number of variable names beginning With underscore are resolved for system Use using them in your program may cause Problems in your code execution  it’s better to avoid such Names C language is case sensitive means Uppercase and lowercase letters are Distinctive writing.
      You can also assign variable to a variable instead of this constant value 3 or 4.int var1 is equal to 3. Suppose my new variable is var1,I declare another variable var2 and I initialized or you can say I assigned value to it  with the value of var1.Here you can see that I am assigning the value of 3 actually because writing the name of the variable means that I am assigning its constant value and I'm assigning it to variable 2. Lets print it using printf.Lets debug As expected, the output turns out to be 3.You can also assign same values to different  variables in a single line.As you can see I declared and defined variables in the same line using the same data type.All these variables are of integer type.Instead  of defining and declaring in different lines it is better to write them down  in a single line.Suppose I assign them the value equal to 4 all in the same  line and then I print it.
        Lets build and run.And as expected we get the value 4 4 4 because we had printed three times.There are three different variables var1 var2 var3. Because all of them has been assigned to the same value 4 That is why we are getting three values of 4 in the output. 
         Where all are different you can say It is interesting to know that Traditionally lowercase letters are used For naming the variables and uppercase Letters for naming symbolic constants Will talk about symbolic constants when  We study the use of hash define later Special characters such as at the rate Hound percentile power ampersand star Etcetera other than underscore are not Allowed in the name of variables note Maybe some special characters use in Naming variable can work but most of Them failed like when I put dollars Somewhere in between or even at the Beginning of the variable name it works But if I choose some other special Character like percentile it produces Error therefore battle is to avoid the Use of special characters but yes I told You to avoid using underscore at the Beginning but you can use it in between The name of the variables blanks or you Can say white spaces are not allowed in Between for the separation of different Parts of the name of variable. 
         for Example in my variable is invalid Because of the blank space over here you Can see blank space compiler won’t be Able to recognize it as a single Variable instead if you want to improve Readability you can use underscore Instead of blank space int my variable Is now a valid variable name as you can See over here now I’d put underscore Instead of that blank space keyword Slight if-else for wild switch int float Long double etc are result words you Cannot use them in naming your variables Although all these keywords are Lowercase and if you insist to use them In naming your variables you can make Either a Or multiple letters uppercase and then You can use them like this finally there Is one important tip do not use longed Name for your variables it may not look Good and using them later in your Program is not that easy because you Have to write down those long names Again and again in your code whenever You want to use them that’s it for now See you in the next lecture.

कोई टिप्पणी नहीं:

एक टिप्पणी भेजें

Data Types in C (part 2)

        Data Types in C.......             Today, we will continue our discussion on integer data type. Our outline for today...