Tips and Tricks for declaring Variables

Tips and Tricks for declaring variables


Declaring variables is not a easy task. It is a difficult and mind confusing task. So here, I am providing some tips that can help you to declare variables easily in C Programming.

Always try to follow following points :

1. Every variable name must start with a letter(a-z , A-Z) or a underscore( _ ) 

2. Never start a variable name with numbers,symbols,etc

3. A variable should not contains special characters like $  < * & ^ % #, etc

4. A variable can contain only digits,letters(it may be upper case or a lower case),underscore

5. Variables must be realistic and connected to real life problem, for example if you are writing a        program for calculating total marks of student then use the variables like total_marks,etc

6. Do not use short,letter names. for example, to store student total marks don't use the variables like a,b,f,m,etc. they are confusing names. 

7. Avoid too much long names.

8. You can use following naming pattern.

* Camel Case : In this case the first letter of each word in a compound word is capitalized. For example, variable for  total marks in camel case can be written as TotalMarks.
  In this letter 'T' of  total and letter 'M' of marks is capitalized.

* Pascal Case : In this case, generally the first letter of every word in  a compound word is capitalized except that the first letter of first word is in lower case. For example,variable for total marks in pascal case can be written as totalMarks. 
In this only 'M' of marks is capitalized.

9. Naming a variable is case sensitive. It means that Marks and marks is different and they are different variables. It is better to avoid such situations.

10. Never use a reserved keyword of C for naming a variable. For example,you cannot use void as a variable name.

   

Comments

  1. Congratulation for the great post. Those who come to read your Information will find lots of helpful and informative tips.
    get more: Programming in C

    ReplyDelete

Post a Comment

Popular posts from this blog

Coding tips for Developers

Master Data Structure & Algorithms in Python

How to Start with Coding: A Beginner's Guide