Elements of C programming | Learn C | Village Programmer




Elements of C Programming

This is the second article of the series Learning C Programming Language


Every language has some basic elements & grammatical rules. Before starting with programming,
we should be acquainted with the basic elements that build the language.

🔅 Character Set: 

Communicating with a computer involves speaking the language the computer understands. In C,
various characters have been given to communicate.
Character set in C consists of : 

Types
Character Set
Lower case
 a-z
Upper case
A-Z
Digits
0-9
Special Character
!@#$%^&*
White space
Tab or new lines or space

🔅 Keywords:

Keywords are the words whose meaning has already been explained to the C compiler. The keywords cannot be used as variable names because if we do so we are trying to assign a new meaning to the keyword, which is not allowed by the computer.
There are only 32 keywords available in C. Below figure gives a list of these keywords for your
ready reference.


auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while

🔅 Identifier:

In the programming language C, an identifier is a combination of alphanumeric characters, the first being a letter of the alphabet or an underline, and the remaining being any letter of the alphabet, any numeric digit, or the underline.
Two rules must be kept in mind when naming identifiers.
  • The case of alphabetic characters is significant. Using "INDEX" for a variable is not the same as using "index" and neither of them is the same as using "InDeX" for a variable. All three refer to different variables.
  • As C is defined, up to 32 significant characters can be used and will be considered significant by most compilers. If more than 32 are used, they will be ignored by the compiler.

🔅 Datatype:

In the C programming language, data types refer to a domain of allowed values & the operations that can be performed on those values. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. There are 4 fundamental data types in C, which are- char, int, float &, double. Char is used to store any single character; int is used to store any integer value, float is used to store any single precision floating point number & double is used to store any double precision floating point number. We can use 2 qualifiers with these basic types to get more types.

There are 2 types of qualifiers-
  • Sign qualifier- signed & unsigned
  • Size qualifier- short & long
The data types in C can be classified as follows:


Type
Size
Value Range
char
1 byte
-128 to 127
unsigned char
1 byte
0 to 255
int
2 or 4
bytes
-32,768 to 32,767
Or -2,147,486,648
to 2,147,486,647
unsigned int
2 or 4
bytes
0 to 65,535 or
0 to 4,294,967,295
float
4 bytes
1.2E-38 to 3.4E+38
(6 decimal precision)
double
8 bytes
2.3E-308 to 1.7E+308
(15 decimal precision)
long double
10 bytes
3.4E-4932 to 1.1E+4932
(19 decimal precision)

Constants and Variables also are elements of C.
But we will discuss them in the next article. 😀

Thanks for reading. 🙏
If you liked it feel free to share with your dear ones.💗
And tell me what do you think in the comment box.💬

Post a Comment

Previous Post Next Post