A C identifier can be a name used to identify a variable, function, or any other user-defined item. An identifier can start with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9).
C is not allowing punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming language. Thus, hello and Hello are two different identifiers in C.
What are the naming rules for a C identifier ?
An Identifier can contain only alphanumeric characters(a-z , A-Z , 0-9) and underscore(_).
The first character of an identifier should be an alphabet(a-z , A-Z) or underscore (_). Means numeric (0-9)can not be used as the first character of a C identifier.
Identifiers are case sensitive in C. For example roll and Roll are two different identifiers in C.
Reserved keywords are not allowed to be used as Identifiers.
No special characters, such as period, semicolon, white spaces, comma or slash are permitted to be used in or as Identifier.
What is keyword in C programming ?
Keywords are reserved words and have special meaning in C language. The specific meaning of C language keywords has already been described to the C compiler. These meaning cannot be changed. Thus, keywords cannot be used as variable names or for any other purpose because that would try to change the existing meaning of the keyword, which is not allowed. There are total 32 keywords in C language.
What is the use of white spaces in C program ?
White space is the term used in C to describe blanks, tabs, newline characters. Some times white spaces are necessary as in the case of below statement.
there must be at least one white space character (usually a space) between int and roll for the compiler to be able to distinguish them as two different tokens.
On the other hand, in the following statement −
total = no1 + no2; // add no1 and no2 and store to total
Whitespace characters are not necessary between total and = operator, or between = operator and no1 variable, although you are free to include some if you wish to increase readability. So in this case white spaces are optional.
What are the basic rules while writing a C programming Syntax or Statement ?
We have to follow these basic rules while writing a C programming Syntax or Statement.
C is a case sensitive language means Student and student have different meaning to C.
All C statement must end with a semicolon.
White space is used in C normally to describe blanks and tabs.
White space is required between keywords and identifiers.
White space can be used for better readability.
Variables in C Programming
When we want to store any data or information, we store it in the computer’s memory. But we do not remember the memory locations. We simply remember the name of files. The operating system knows in which memory location that file was stored.so that it becomes easier for us to find it and access it.
Similarly, in C language, when we want to use some data value in our program, we can store it in a memory space and name it so that further we can access it easily.
So a variable in simple terms can be defined as a named storage space which has some memory allocated to it. As its name suggests it has the ability to change its value. Means we can change the value of this named memory location when ever needed.
So basically a variable is used to store some form of data. We should remember that different types of variables require different amounts of memory space in computers memory and have some specific set of operations which can be applied on them.
My Self Subrat Dash. I have completed my MSc in Information Technology. Since last 12 years i am teaching Math and Computer at TTRC Computer Institute situated at Rayagada, Odisha, India.
I believe in conceptual learning, so i explain each and every concept with demos and examples, which makes it easier to understand.