Unit-I _ C-Programming
Unit-I _ C-Programming
of with
Hours CO
L T/A CO
Number
UNITDetails of Topic to C programming
1: Introduction
Basic structure of C program, Features of C language, Character set, C 7
tokens, Keywords and Identifiers, Constants, Variables, Datatypes 1
Subroutine Section: All user defined functions that are called in main function should be
defined.
1.2. Features of C language
Features of C Language */ Advantages /*
C language is very popular language because of the following features:
1. C is structured Programming Language
2. It is considered a high-level language because it allows the programmer to solve a
problem without worrying about machine details.
3. It has wide variety of operators using which a program can be written easily to solve a
given problem.
4. C is more efficient which increases the speed of execution and management of
memory compared to low level languages.
5. C is machine independent. The program written on one machine will work on another
machine.
6. C can be executed on many different hardware platforms.
1.3. Character set
1.3 Character set of C language
Definition: A symbol that is used while writing a program is called a character.
A character can be: .
Alphabets/Letters (Lowercase a-z, Uppercase A-Z)
Digits (0-9)
Special Symbols ( ~ ‘ ! @ # % & * () - + / $ = \ { } [ ] : ; “ “ ? etc)
Tokens
Special
Keywords Identifiers Constants Operators
Symbols
1.5. Keywords
Words.
totally 32 keywords supported in C they are:
Definition:
2. No extra symbols are allowed other than letters ,digits and Underscore
3. Keywords cannot be used as an identifier
4. The length can be 31 characters for external, 63 for internal.
5. Identifiers are case sensitive.
Example: Area, Sum_
1.7. Constants,
Definition:
1. Integer constant
2. Real constant/Floating Pointing constant
3. Enumeration constant
4. Character constant
5. String constant
1. Integer constant
-
Ex: 123 , -345, 0 , 5436 , +79
but it has a
prefix of 0
Ex: 027 , 0657 , 0777645
with 0X or 0x
Ex: 0X2 0x56 0X5fd 0xbdae
i. Fractional form:
-71.
ii. Exponential form:
ger.
–
-3 => 9.86*10
3
3. Enumeration constant
enumeration constants.
NO is assigned with 0
YES is assigned with value 1
d is followed
by one character.
5.String constant
A sequence of characters enclosed within pair of double quotes is called string constant.
The string always ends with a NULL character.
Ex: “9” , “SVIT”
Variables,
1.4.4.1Declaration of variables:
Giving a name to memory location is called declaring a variable.
Reserving the required memory space to store the data is called defining a variable.
General Syntax:
datatype variable; (or)
datatype variable1, variable2,……..variablen;
example: int a;
float x, y;
double sum;
From the examples we will come to know that “a” is a variable of type integer and
allocates 2 bytes of memory. “x” and “y” are two variable of type float which will be
allocated 4 bytes of memory for each variable. “sum” is a double type variables
which will be allocated with 8 bytes of memory for each.