Basics of C
Basics of C
UNIT-I
1.1 History of c
1.2 Importance of ‘C’ language
1.3 Basic Structure of C Program
1.4 programming Style:
.1.5 Character set
1.6 C Tokens
1.6.1. Keywords and Identifiers
1.6.2. Constants
1.6.3. Strings
1.6.4. Special Symbols
1.6.5. Operators in C
1.7 Variables
1.8 Data types
1.9. Declaration of variables
1.10. Defining symbolic constants
1.11. Declaring variable as constants
1.12. Overflow and underflow of data
1.13. Operators
1.13.1. Arithmetic Operators
1.13.2. Relational Operators
1.13.3. Logical Operators
1.13.4. Assignment Operators
1.13.5. Increment and Decrement Operators
1.13.6. Conditional Operators
1.13.7. Bitwise Operators
1.13.8. Special Operators
1.14. Expressions
1.15. Evaluation of expression
1.16. Precedence of arithmetic Operator
1.17. Type conversion in expressions
1.18. Operator precedence and Associativity
1.19. Mathematical function
1.1 History of c
1. It is robust language whose rich setup of built in functions and operator can be used to
write any complex program.
2. Program written in C are efficient due to several variety of data types and powerful
operators.
3. The C compiler combines the capabilities of an assembly language with the feature of
high level language. Therefore it is well suited for writing both system software and
business package.
4. There are only 32 keywords; several standard functions are available which can be used
for developing program.
5. C is portable language; this means that C programs written for one computer system can
be run on another system, with little or no modification.
6. C language is well suited for structured programming, this requires user to think of a
problems in terms of function or modules or block. A collection of these modules make a
program debugging and testing easier.
1. It has to use lowercase letters. Uppercase only used for symbolic constant.
1. Letters
2. Digits
3. Special characters
4. White space
Letters
C language supports all the alphabets from the English language. Lower and upper case letters
together support 52 alphabets.
lower case letters - a to z
UPPER CASE LETTERS - A to Z
Digits
C language supports 10 digits which are used to construct numerical values in C language.
Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special characters
C language supports a rich set of special characters- camma,period semicolon colan,question
mark ect( ~ @ # $ % ^ & * ( ) _ - + = { } [ ] ; : ' " / ? . > , < \ |)
white spaces, backspaces,harizantal tab,carriage return,newline,form feed.
1.6 C Tokens
The smallest individual unit are known as tokens. C has six types of tokens as shown in fig.
1. Integer constants
2. Real or Floating point constants
3. Octal & Hexadecimal constants
4. Character constants
5. String constants
6. Backslash character constants
1.6.3. Strings
The string constants are a sequence of characters enclosed in double quotes. A string is an
array of characters ended with a null character (\0). This null character indicates that
string has ended. Strings are always enclosed with double quotes (“ “).
Let us see how to declare String in C language −
1.6.5. Operators in C
Operators is a special symbol used to perform the functions. The data items on which the
operators are applied are known as operands. Operators are applied between the
operands.
1.7 Variables
A variable is a data name that may be used to store a data value. the values can be
changed during the execution time.
Rules for variable names