0% found this document useful (0 votes)
2K views

#2 Identifiers in C Language PDF

Uploaded by

Atul Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

#2 Identifiers in C Language PDF

Uploaded by

Atul Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

#2 Identifiers in C Language

C Notes Vol-1 by Saurabh Shukla


www.mysirg.com

#2 Identifiers in C Language
By Saurabh Shukla | 2017©mysirg.com

Begin Learning C

Computer languages are like natural languages. Natural languages like Hindi, English, and German
are used for the communication between human beings. Computer languages are used to prepare a
script to perform actions by the machines.

Language is just a medium to express your thoughts. When we want to say something to a machine
to do some task, we just trigger the script (program) by clicking on some file or clicking on some
button or may be hitting some key on the keyboard. This script or program is prepared in some
computer programming language.

Developing program is the job of programmer. You need to learn language to become a
programmer.

Learning steps are very similar to the process you must have gone through at early stages of your
schooling. When you were a kid, you were supposed to learn alphabets in English. Swar and vyanjan
in Hindi. In the same way you have to begin learning C language.

Following are the steps

1. Learn basic letters used in C language


2. Learn Identifiers
3. Learn Instructions
4. Develop programs
#2 Identifiers in C Language
C Notes Vol-1 by Saurabh Shukla
www.mysirg.com

You are already familiar with the basic letters as you have seen them on keyboard. So we should
start our journey of learning from identifier

Identifier

Smallest identifying unit in the program is known as identifier. In English you call it a word. In
programming language it is known as identifier. Identifiers can be categorized as constants,
variables, keywords, macros, functions, etc.

As of now we are only going to see constant, variable and keywords. Rest of the identifiers will be
covered in later chapters.

Constant

Any information is constant. Every program you make is to process data. For example, program to
add two numbers or calculate simple interest, etc. You need some data to process. In addition of
two numbers program, you need two numbers to perform task. Similarly, in simple interest program
you need principle, time and rate of interest information, and then only you can process it. In a nut
shell, this data is called constant.

Data=Information=Constant

Information or constant can be classified which gives us ease of handling data in our program.
Number is a constant, your name is also constant but you cannot perform multiplication between
#2 Identifiers in C Language
C Notes Vol-1 by Saurabh Shukla
www.mysirg.com

two names. So data can be categorized on the basis of kind of operations we can perform on it and
on internal binary representation.

In c language constants are classified as:

 Primary constants
 Secondary constants

Primary constants are further categorized as

 Integer
 Real
 Character

Secondary Constants are categorized as

 Array
 String
 Pointers
 Structure
 Union
 Enumerator
#2 Identifiers in C Language
C Notes Vol-1 by Saurabh Shukla
www.mysirg.com

Numbers without decimal points are known as integers.

Numbers with decimal point are known as real constants.

Any symbol in single quotes is known as character constant.

Variables

When you run any program, it consumes memory in RAM till its execution in process. To perform a
task program can use this memory for various reasons. One of the important reasons is to store
needful data, which is going to be used in processing. In addition of two numbers program, program
needs to preserve two data until addition task is over. You need to reserve memory blocks to store
these data, and these memory blocks should be named for future reference in the program.

It depends on the program, how many memory blocks are required to handle data. In addition of
two numbers, three memory spaces should be reserved, two blocks for two numbers that to be
added and third block is to store result.

These memory blocks are variables. They have names for identification.

In the above diagram, a,b,c are variables.

Variable name is any combination of alphabet, digit and underscore. No other symbol is permitted.
#2 Identifiers in C Language
C Notes Vol-1 by Saurabh Shukla
www.mysirg.com

Valid variable name cannot start with digit.

Keywords

Keywords are predefined words; their meaning is already known to compiler. Every word you are
using in the program must have known to compiler. If the meaning is not known to compiler then it
will yield an error. To avoid error, you have to declare such words to compiler by declaration
statements. Keywords are the words, whose meaning is already defined; you can directly use them
for specific reason.

There are 32 keywords according to the ANSI standard, but sometimes compiler may support
additional keywords too.

We will see these keywords wherever required in the later chapters.

Remember

 Syntax means grammer


#2 Identifiers in C Language
C Notes Vol-1 by Saurabh Shukla
www.mysirg.com

References

YouTube video links

 Lecture 2 Identifiers in C language


o https://www.youtube.com/watch?v=4RvPihzs6uw&feature=youtu.be&list=PL7ersPs
TyYt2Q-SqZxTA1D-melSfqBRMW

Exercise

1. In which category following data falls (Integer, Character, Real, String, Array, Structure, etc)
a. Mobile number
b. Name of a city
c. Rate of interest
d. Number of family members
e. Percentage
f. Your name
g. Password
h. Email id
i. Grade
2. Tick the correct variable name
a. A1
b. X-2
c. abc@12
d. 2f
e. M_23_a
f. Aa
g. W$
h. Emp id
i. FLOAT
j. float

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy