
- C Programming
- introduction of c language
- Introduction of C programming
- what is Array and types of arrary
- Basic Structure of C Program
- C Program to Generate Multiplication Table
- C Programming Operators and Expressions
- Data Types In C Programming
- C Keywords and Identifiers
- Types of Arrays in C Progarmming
- pointer in c language
- C program to print patterns of numbers and stars
C Keywords and Identifiers
In this tutorial, you will learn about keywords and identifiers in C programming that are part of the syntax. Also, you will learn about identifiers and the proper way to name a variable. Keywords and identifiers in C programming play an important role in Coding in c.
C Keywords and Identifiers
C Programming Identifiers
In C language identifiers are the names given to variables, constants, functions, and user-defined data. These identifiers are defined against a set of rules.
Example
int marks;
char studentName[30];
Here, marks and student names are identifiers.
Rules for writing an identifier
- An Identifier can only have alphanumeric characters( a-z, A-Z, 0-9 ) and an underscore( _ ).
- The first character of an identifier can only contain the alphabet( a-z, A-Z ) or underscore ( _ ).
- Identifiers are also case-sensitive in C. For example, name and Name are two different identifiers in C.
- Keywords are not allowed to be used as Identifiers.
- No special characters, such as semicolons, periods, whitespaces, slash, or commas are permitted to be used in or as Identifier.
C Keywords
Keywords are specifically reserved, predefined words in C each of which has a specific feature associated with it. Almost all of the words which help us use the functionality of the C language are included in the list of keywords. So you can imagine that the list of keywords is not going to be a small one!
Properties of Keywords
- All the keywords in C programming language are defined as lowercase letters so they must be used only in lowercase letters.
- Every keyword has a specific meaning, users can not change that meaning.
- Keywords cannot be used as user-defined names like variables, functions, arrays, pointers, etc..
- Every keyword in C programming language represents something or specifies some kind of action to be performed by the compiler.
There are a total of 32 keywords in C these are given below in the table
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 |
Basics usage of these keywords –
if, else, switch, case, default – Used for decision control programming structure.
break – Used with any loop OR switch case.
int, float, char, double, long – These are the data types used during variable declaration.
for, while do – types of loop structures in C.
void – One of the return types.
goto – Used for redirecting the flow of execution.
auto, signed, const, extern, register, unsigned – defines a variable.
return – This keyword is used for returning a value.
continue – It is generally used with for, while, and do-while loops, when the compiler encounters this statement it performs the next iteration of the loop, skipping the rest of the statements of the current iteration.
enum – Set of constants.
size of – It is used to know the size.
struct, typedef – Both of these keywords are used in structures (Grouping of data types in a single record).
union – It is a collection of variables, which shares the same memory location and memory storage
In this tutorial, you will learn about keywords and identifiers in C programming that are part of the syntax. Also, you will learn about identifiers and the proper way to name a variable.