Skip to main content

Keywords and Identifiers in C


C Keywords
Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier. For example:
int money;
Here, int is a keyword that indicates 'money' is a variable of type integer. 
As C is a case sensitive language, all keywords must be written in lowercase. Here is a list of all keywords allowed in ANSI C.
Keywords in C Language
auto
double
int
struct
break
else
long
switch
case
enum
register 
typedef
char
extern
return
union
continue
for
signed
void
do
if
static 
while
default
goto
sizeof
volatile
const
float
short
unsigned
Along with these keywords, C supports other numerous keywords depending upon the compiler.
All these keywords, their syntax and application will be discussed in their respective topics. However, if you want a brief overview on these keywords without going further, visit list of all keywords in C programming.
C Identifiers
Identifier refers to name given to entities such as variables, functions, structures etc.
Identifier must be unique. They are created to give unique name to a entity to identify it during the execution of the program. For example:
int money;
double accountBalance;
Here, money and accountBalance are identifiers.
Also remember, identifier names must be different from keywords. You cannot use int as an identifier because int is a keyword.
Rules for writing an identifier
A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
The first letter of an identifier should be either a letter or an underscore. However, it is discouraged to start an identifier name with an underscore.
There is no rule on length of an identifier. However, the first 31 characters of identifiers are discriminated by the compiler.
Good Programming Practice
You can choose any name for an identifier (excluding keywords). However, if you give meaningful name to an identifier, it will be easy to understand and work on for you and your fellow programmers.


Comments

  1. your article is nice
    web programming tutorial
    welookups.com

    ReplyDelete
  2. I have read all your articles. I wonder why you can write them. They are easy to understand and accessible. They help me much too. I'm thankful if you can upload more posts later. Thanks for your sharing.
    Hướng dẫn đăng ký B30 VinaPhone, Đăng ký Mimax sinh viên VinaPhone, Đăng ký Mimax50 VinaPhone, Đăng ký 3G VinaPhone 1 ngày chỉ 5K,7K,10K

    ReplyDelete
  3. I'm trying to learn more knowledge and your articles are so useful for me. I can understand them easily. They aren't science rocket. I even can apply them in ordinary life. I'm grateful for your sharing. I hope you will write often and post more articles. email-with-love free online2018,apps email-with-love, http://dichvuvina.vn

    ReplyDelete

Post a Comment

Popular posts from this blog

Files in C

A file is a repository of data that is stored in a permanent storage media, mainly in secondary memory. In order to use the files we should learn how to read information from a file and how to write information into a file. A very important concept in C is the stream.The stream is a common logical interface to the various devices( files).A stream is linked to a file while using an open operation. A stream is disassociated from a file while using a close operation. The current location, also referred to as the current position, is the location in a file where the next fie access will occur.There are two types of streams text and binary. The following are some difference between text and binary files ·Text file is human readable because everything is stored in terms of text. In binary file everything is written in terms of 0 and 1, therefore binary file is not human readable. ·A newline(\n) character is converted into the carriage return-linefeed combination before being written to the d…

KTU C programming question paper and evaluation scheme

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY SECOND SEMESTER B.TECH DEGREE EXAMINATION, MAY 2017 CS 100 COMPUTER PROGRAMMING (CS, IT) SCHEME OF EVALUATION
PART A 1 An identifier is a sequence of characters invented by the programmer or to identify or name a specific object. The sequence of characters may be letters, digits, and special character ‘_’known as an underscore Rules: i)Identifiers should start with alphabets. ii)Identifiers are case sensitive iii)A numeric digit should not be the first character iv)Identifier name should not be a keyword v)Identifier may be of any reasonable length 1mark






2mark 2 Associativity defines the direction, left to right or right to left in which operator act upon its operands Unary operators have associativity is from right to left. For examplein the expression &--x, pre decrement works first and then address of operator works Direction + example<

Linear and Binary Search in C

Searching is one of the most common problems that arise in computing. Searching is the algorithmic process of finding a particular item in a collection of items. A search typically answers either True or False as to whether the item is present. On occasion it may be modified to return where the item is found. Search operations are usually carried out on a key field. Consider searching for a given value k in an array A of size n. There are 2 basic approaches: sequential search and binary search.
Linear (Sequential) Search When data items are stored in a collection such as a list or array , we say that they have a linear or sequential relationship. Each data item is stored in a position relative to the others. In C array, these relative positions are the index values of the individual items. Since these index values are ordered, it is possible for us to visit them in sequence. This process gives rise to our first searching technique, the sequential search. Starting at the first item in …