Search

Basic Concepts

                         Basics of C programming

This page will explain you basic concepts of C programming language. Following C language basic concepts are discussed through various programs given on this page: 

data types, declaring variables, assigning values to variables, processing values of variables, displaying content to the console, and reading user input.

Rules for defining Variable Name in C language



In C language any user-defined name is called identifier.
 This name may be a variable name, function name, goto label name, 
or any other data type name like structure,
 union, enum name or typedef name. 
We need to follow some rules while 
declaring variables (identifiers) in the C program. 
To know more about variable

In C language any user defined name is called identifier. This name may be 
variable name, function name, goto label name, any other data type name like 
structure,union, enum names or typedef name.

We need to follow following rules while declaringvariables (identifiers) in C program.

Rule 1:  Name of identifier includes 
alphabets, digit and underscore.

Example of Valid variable name:
 india, add12, total_of_number etc.

Example of Invalid variable name: 
show*marks, factorial#, avg value etc.

Rule 2: First character of any identifier must be 
either alphabets or underscore.

Valid name:  _total, _3, a_,   etc.

Invalid name: 3_, 10_function, 12345 etc.

Rule 3: Name of identifier cannot be any keyword 
of c program.

Invalid name: int, float, char, if, else, for, switch, etc

Rule 4: Name of identifier is case 
sensitive i.e. num and Num are two different variables.

Rule 5: Only first 31 characters are significant of   identifier name.

Example:

abcdefghijklmnopqrstuvwxyz123456aaa, 

abcdefghijklmnopqrstuvwxyz123456bbb, 

abcdefghijklmnopqrstuvwxyz123456cad

All three identifier name are same because only first 31 characters has meaning. Rest has not any importance.

Rule 6: Must not contain white space.

Valid name: MyMarks

Invalid name: My Marks




No comments:

Post a Comment