Rules for constructing variables in C Language
The above video is an extract from the online course – “C Programming: The ultimate guide for beginners” which we are currently working on. Consider subscribing to Youtube channel – Aptuts in order to get latest updates on new videos and online C programming course.
Variables in C are entities whose value keeps on changing throughout the program execution. As we all know, data is stored in the memory of the computer. Actually, data is not stored in the variable. A variable is the name given to the memory location. A variable name is an entity that points to a particular memory location.
Rules for constructing variables in C
- A Variable name consists of any combination of alphabets, digits and underscores. Some compiler allows variable names whole length could be up to 247 characters. Still it would be safer to stick to the rule of 31 characters. Please avoid creating long variable name as it adds to your typing effort
- The first character of the variable name must either be alphabet or underscore. It should not start with the digit
- No commas and blanks are allowed in the variable name
- No special symbols other than underscore are allowed in the variable name
We need to declare the type of the variable name before making use of that name in the program. Type declaration can be done as follows:
To declare a variable as integer, follow the below syntax:
Here int is the type of the variable named variable_name. ‘int’ denotes integer type.
Following are the examples of type declaration statements:
int p, n; float r;
To learn more about variables in C, visit – Variable, Constant and Keyword in C
I agree with you. This site is excellent. Great work. Keep going.
great work man
Hi this is raju. Learn c language through online is very good idea . It is very useful to beginners. Already known persons increase their knowledge.
its realy helpng me for learning basics of C..
Thanks to all of you or appreciating my work.
Well thank you for giving us work to appreciate!
can u explain int variable_name nd giv another eg
E.g: int flag;
In the above declaration, flag is a variable that with hold an integer value.
we can set the value of the above variable as follows:
flag = 0;
Here value 0 gets stored in the variable flag.
why cannot the variable name start with a number?
This site and its tutorial on C programming is off the hook
good jOb admin
Thank you everyone for the wonderful comments. I hope this website is helping every one out there.
If you like this website, kindly share it with everyone.
as told no special character is allowed.
Why $jd is a variable?
try to create a variable with name $a, it gets compiled using gcc
helped a lot
wht r different rules to define a variable with example
i appreciate the good work
Thank you Jackson. Happy learning and all the best.
http://www.aptuts.com – One Stop Webinar Coaching
NIce to see ur website, As a Professor I can learn more with the use of ur web-site………Congrats & Keep this great wrk
It is my pleasure to hear such a great feedback from a professor. Thank you 🙂
I agree with you. this site is excellent
Truly! Simple and crystal clear. Good job bro.