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.There are 32 keywords.

Keywords In C

Along with these keywords, C supports other numerous keywords depending upon the compiler.


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. 
  • Identifiers are case sensitive ie; X is different from x.
  • Keywords should not be used as identifiers.
The following are valid identifiers
x    y12     sum_1     _temperature     names     area     tax_rate  TABLE

The following names are not valid identifiers for the reasons stated.
2csbmec        The first character must be a letter.
mec#cs2b      Illegal character  #.
order-no         Illegal character (-).
mec cs2b        Illegal character (blank space)

An identifier can be arbitrarily long. Some implementations of C recognize only the first eight characters, though most implementations recognize more (typically, 31 characters).The identifiers file-manager and file-management are both grammatically valid. Some compilers may be unable to distinguish between them, however, because the first eight letters are the same for each identifier. Therefore, only one of these identifiers should be used in a single C program.

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. Looking forward to reading more. Great post. Really looking forward to read more. Keep writing. I think this is a real great post. Really looking forward to read more. Really Cool
    sales notifications app

    sales pop master

    ReplyDelete
  4. Looking forward to reading more. Great post. Really looking forward to read more. Keep writing. I think this is a real great post. Really looking forward to read more. Really Cool
    Discount master app


    Discount master app

    ReplyDelete
  5. For space outside the milk tea shop closer to nature, outdoor space should use speakers with greater capacity, products such as garden speakers, imitation stone speakers, are products with designs The most natural to create interesting feeling when enjoying. Because it must work in the weather conditions heat so the shell is made very firmly with high durability, the quality of the speaker is imported genuine. Good sound, making good clear sound even when used in wide space
    Gái gọi Mỹ Đình - Đình Thôn, gái gọi Nguyễn Khánh Toàn, gái gọi hà nội, gái gọi Phố Cổ - Quán Sứ

    ReplyDelete
  6. Looking forward to reading more. Great blog.Really looking forward to read more. Keep writing
    app autoketing
    https://apps.shopify.com/shipping-bar-master
    https://bit.ly/2BXG37u

    ReplyDelete

Post a Comment

Popular posts from this blog

KTU Mandatory C programs for Laboratory and Solutions

LIST OF LAB EXPERIMENTS 1. Familiarization of Hardware Components of a Computer 2. Familiarization of Linux environment – Programming in C with Linux 3. Familiarization of console I/O and operators in C     i) Display “Hello World”     ii) Read two numbers, add them and display their sum     iii) Read the radius of a circle, calculate its area and display it 4. Evaluate the arithmetic expression ((a -b / c * d + e) * (f +g))   and display its solution. Read the values of the variables from the user through console 5. Read 3 integer values, find the largest among them. 6. Read a Natural Number and check whether the number is prime or not 7. Read a Natural Number and check whether the number is Armstrong or not 8. Read n integers, store them in an array and find their sum and average 9. Read n integers, store them in an array and search for an element in the    array using an algorithm for Linear Search 10.Read n integers, store them in an array and sort the elements in t

PROGRAMMING IN C KTU EST 102 THEORY AND LAB NOTES

PROGRAMMING IN C  KTU  EST 102  THEORY AND LAB   COMMON FOR ALL BRANCHES About Me Syllabus Theory Syllabus Lab Model Question Paper EST 102 Programmin in C University Question Papers  and evaluation scheme   EST 102 Programming in C  Introduction( Lab) Introduction to C programming Linux History and GNU How to create a bootable ubuntu USB stick Installing  Linux Install Linux within  Windows Virtual Box and WSL Linux Basic Features and Architecture Basic Linux Commands Beginning C Programming Compiling C programs using gcc in Linux Debugging C program using gdb Module 1: Basics of computer hardware and software          Module-1 Reading Material Basics of Computer Architecture Hardware and Software System Software and Application Software  Programming Languages ( High level, Low level and Machine Language) and Translators ( Compiler, Interpreter, Assembler) Algorithm, Flowcharts and Pseudo code Program Development Structured Programming Basics of hardware ( video) Know about Motherboar

Arrays in C-single and multi dimensional arrays- list and matrix

An array is a collection of data items, all of the same type, accessed using a common name. A one-dimensional array is like a list(vector); A two dimensional array is like a table(matrix). We can have more dimensions. Always, Contiguous (adjacent) memory locations are used to store array elements in memory. Elements of the array can be randomly accessed since we can calculate the address of each element of the array with the given base address and the size of the data element. Declaring  Single Dimensional Arrays Array variables are declared identically to variables of their data type, except that the variable name is followed by one pair of square [ ] brackets for mentioning dimension of the array.  Dimensions used when declaring arrays in C must be positive integral constants or constant expressions.  In C99, dimensions must still be positive integers, but variables can be used, so long as the variable has a positive value at the time the array is declared. ( Space is allo