MODULE 1
INTRODUCTION TO C LANGUAGE
Syllabus
Pseudo code Solution to Problem
Basic Concepts of C Program
Declaration, Assignment & Print Statements
Data Types
Operators and Expressions
Programming Examples and Exercise.
Introduction to C
C is a general-purpose programming language developed by Dennis Ritchie at AT&T
Bell laboratories in 1972.
Advantages/Features of C Language
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.
Pseudocode: A solution to Problem
Definition:
It is a series of steps to solve a given problem written using a mixture of English and
C language.
It acts as a problem solving tool.
It is the first step in writing a program.
, Purpose:
Is to express solution to a given problem using mixture of English language
and c like code.
Advantage:
Easy to write and understand
It is relatively easy to convert English description solution of small programs to C
program.
Ex 1: Addition of two numbers
1. Get the numbers[a,b]
2. Compute addition [Sum= a + b]
3. Print the results [Sum]
Ex 2: Area of Circle
1. Get the radius[r]
2. Compute area[Area = 3.141*r*r]
3. Print the results [Area]
Disadvantage:
It is very difficult to translate the solution of lengthy and complex problem in English to
C
C Programming Concepts
Program: A program is a group of instructions given by the programmer to perform a
specific task.
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)
, Symbol Name Symbol Name Symbol Name
~ | [
Tilde Vertical bar Left bracket
# hash ( Left parenthesis ]
Right bracket
$ Dollar sign ) Right parenthesis
: Colon
% Percent sign _ Underscore ” Quotation
mark
^ + Plus sign ;
Caret Semicolon
& Ampersand { <
Left brace Less than
* Asterisk } Greater than
Right brace >
Assignment
‘ Single quote . dot =
Division
, comma \ backslash /
C Tokens
Tokens are the smallest or basic units of C program.
One or more characters are grouped in sequence to form meaningful words.these
meaningful words are called as tokens.
A token is collection of characters.
Tokens are classified in to 5 types as below:
, Keywords
The tokens which have predefined meaning in C language are called keywords.
They are reserved for specific purpose in C language they are called as Reserved
Words.
There are totally 32 keywords supported in C they are:
auto double if static
break else int struct
case enum long switch
char extern near typedef
const float register union
continue for return unsigned
default volatile short void
do goto signed while
Rules for keywords
1. Keywords should not be used as variables ,function names, array names etc.
2. All keywords should be written in lowercase letters.
3. Keywords meaning cannot be changed by the users.
Identifiers
Definition:
Identifiers are the names given to program elements such as variables, constants ,function
names, array names etc
It consists of one or more letters or digits or underscore.
Rules for identifiers
1. The First character should be an alphabet or an underscore _
Then First character is followed by any number of letters or digits.
INTRODUCTION TO C LANGUAGE
Syllabus
Pseudo code Solution to Problem
Basic Concepts of C Program
Declaration, Assignment & Print Statements
Data Types
Operators and Expressions
Programming Examples and Exercise.
Introduction to C
C is a general-purpose programming language developed by Dennis Ritchie at AT&T
Bell laboratories in 1972.
Advantages/Features of C Language
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.
Pseudocode: A solution to Problem
Definition:
It is a series of steps to solve a given problem written using a mixture of English and
C language.
It acts as a problem solving tool.
It is the first step in writing a program.
, Purpose:
Is to express solution to a given problem using mixture of English language
and c like code.
Advantage:
Easy to write and understand
It is relatively easy to convert English description solution of small programs to C
program.
Ex 1: Addition of two numbers
1. Get the numbers[a,b]
2. Compute addition [Sum= a + b]
3. Print the results [Sum]
Ex 2: Area of Circle
1. Get the radius[r]
2. Compute area[Area = 3.141*r*r]
3. Print the results [Area]
Disadvantage:
It is very difficult to translate the solution of lengthy and complex problem in English to
C
C Programming Concepts
Program: A program is a group of instructions given by the programmer to perform a
specific task.
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)
, Symbol Name Symbol Name Symbol Name
~ | [
Tilde Vertical bar Left bracket
# hash ( Left parenthesis ]
Right bracket
$ Dollar sign ) Right parenthesis
: Colon
% Percent sign _ Underscore ” Quotation
mark
^ + Plus sign ;
Caret Semicolon
& Ampersand { <
Left brace Less than
* Asterisk } Greater than
Right brace >
Assignment
‘ Single quote . dot =
Division
, comma \ backslash /
C Tokens
Tokens are the smallest or basic units of C program.
One or more characters are grouped in sequence to form meaningful words.these
meaningful words are called as tokens.
A token is collection of characters.
Tokens are classified in to 5 types as below:
, Keywords
The tokens which have predefined meaning in C language are called keywords.
They are reserved for specific purpose in C language they are called as Reserved
Words.
There are totally 32 keywords supported in C they are:
auto double if static
break else int struct
case enum long switch
char extern near typedef
const float register union
continue for return unsigned
default volatile short void
do goto signed while
Rules for keywords
1. Keywords should not be used as variables ,function names, array names etc.
2. All keywords should be written in lowercase letters.
3. Keywords meaning cannot be changed by the users.
Identifiers
Definition:
Identifiers are the names given to program elements such as variables, constants ,function
names, array names etc
It consists of one or more letters or digits or underscore.
Rules for identifiers
1. The First character should be an alphabet or an underscore _
Then First character is followed by any number of letters or digits.