0% found this document useful (0 votes)
28 views5 pages

Basics of C

Uploaded by

Lena Devaraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

Basics of C

Uploaded by

Lena Devaraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PROGRAMMING IN C -7BCE1C1

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.2 Importance of ‘C’ language

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.

7. C language has its ability to extend itself. A c program is basically a collection of


functions that are supported by the C library. We can continuously add our own functions
to the library with the availability of the large number of functions.
In India and abroad mostly people use C programming language because it is easy to
learn and understand.

1.3 Basic Structure of C Program

The components of the basic structure of a C program consists of 6 parts


1. Document section-The documentation section is the
part of the program where the programmer gives the
details associated with the program. He usually gives
the name of the program, the details of the author
and other details like the time of coding and
description. It gives anyone reading the code the
overview of the code.
2. Preprocessor/link Section-This part of the code is
used to declare all the header files that will be used
in the program. This leads to the compiler being told
to link the header files to the system libraries.
3. Definition section-In this section, we define different
constants. The keyword define is used in this part.
4. Global declaration section-This part of the code is
the part where the global variables are declared. All
the global variable used are declared in this part. The
user-defined functions are also declared in this part
of the code.
5. Main function-Every C-programs needs to have the
main function. Each main function contains 2 parts.
A declaration part and an Execution part. The
declaration part is the part where all the variables are
declared. The execution part begins with the curly
brackets and ends with the curly close bracket. Both
the declaration and execution part are inside the curly
braces.
6. User-defined function section-All the user-defined
functions are defined in this section of the program.

1.4 programming Style:

1. It has to use lowercase letters. Uppercase only used for symbolic constant.

2. Braces used for group the statement together.

3.Group the multiple line in one statement

4.Comments are used for understand the program logic.

1.5 Character set

C language contains the following set of characters...

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.6.1. Keywords and Identifiers


All keywords have fixed meanings and cannot be changed. Keywords are
pre-defined or reserved words in c. there are total 32 keywords in C.

Identifiers: Identifiers refer to the name of a variable, function and arrays.


Rules for identifiers:

 First Character must be an alphabet (or underscore).


 must consist of only letters, digits, or underscore.
 It should be up to 31 characters long.
 Cannot use a keyword.
 must not contain white space.
1.6.2. Constants
Constants: the fixed values do not change during the execution time. Several types
constants as 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 −

 char string[20] = {‘h’,’e’,’l’,’l’,’o’, ‘\0’};


 char string[20] = “WELCOME”;
 char string [] = “WELCOME”;

1.6.4. Special Symbols


Some special backslash character constants are used in Output functions. These
characters combination is known as escape sequences.

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

 The first letter must be an letters(or underscore).


 Variable name has length of 31 characters.
 Uppercase and lowercase are significant
 It should not be a keyword
 White space is not allowed

1.8 Data types

You might also like