C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
This PowerPoint helps students to consider the concept of infinity.
Lecture 6- Intorduction to C Programming
1. Introduction to C Programming
Md. Imran Hossain Showrov (showrovsworld@gmail.com)
6
1
2. Outline
The C Character Set
Identifiers
Keywords
Data Types
Variables
Expressions
Statements
Declarations
3. Objective
This lecture will cover the basic elements used to
construct simple C Statements.These elements
include the C character set, identifiers and keywords,
data types, constants, variables etc.
4. The C Character Set
C uses
The upper case letters (A to Z)
The lower case letters (a to z)
Certain special characters
The Standard requires that an alphabet of 96 symbols
is available for C as follows
6. Writing First Program of C (cont..)
#include <stdio.h>
main()
{
printf(“Welcome to C programmingn”);
}
Output:
7. Writing First Program of C (cont..)
First line of this program uses # as a compiler
directive.
Second line uses a special word main, which denotes
the starting point for execution of the program.All
programs start their execution from main.
{ refers start and } refers end of the main.
printf is an output statement used to display any
message on the screen.
n represents new line.
8. Identifiers
Identifiers are names that are given to various
program elements such as variables, functions and
arrays.
Identifiers consists of letters, digits and underscore
character (_), in any order, But the first character must
be a letter.
9. Identifiers (cont..)
The following names are valid identifiers:
x y12 sun_1 _temperature
names area tax_rate TABLE
The following names are not valid identifiers:
4th The first character must be a letter
“x” Illegal characters (“)
order-no Illegal character (-)
error flag Illegal character (blank space)
10. Keywords
Keywords are reserve words that have standard,
predefined meaning un C.
It can only be used for their intended purpose.
It cannot be used as programmer-defined identifiers.
12. Data Types
Data types are declarations for memory locations or
variables that determine the characteristics of the
data that may be stored and the methods
(operations) of processing that are permitted
involving them.
C supports several data types
13. Data Types (cont..)
Data Type Description Example
int integer quantity 12, 96 etc.
char single character A, b, 0 etc.
float floating-point
number
12.666428
double double-
precision
floating point
number
12.6664287277
62776
14. Variables
A variable is an identifier that is used to represent some
specific type of information within the designated portion
of the program.
Example:
– int a, b, c;
– char d;
– a = 3;
– b= 5;
– c = a + b;
15. Expressions
An expression represents a single data item, such as a number or a
character.
The expression may consist of a single entry, such as a constant.
Expression can also represent logical conditions that are either true or
false.
Example:
●
a + b
●
x = y
●
x <= y
●
x == y
●
c = a + b
●
++i
16. Statements
A statement causes the computer to carry out some action.
There are three different classes of statements in C
1. Expression statement
2. Compound statement
3. Control statement
Example:
a = 3;
c = a + b;
++i;
17. Declarations
A declaration associates a group of variables with a
specific data types.
All variables must be declared before they can appear
in executable statements.
A declaration of a data type, followed by one or more
variable names, ending with semicolon.
Example:
int a, b, c;
float root1, root2;
char flag, text[80];
19. Example 1 (cont..)
Inside the main function:
Identifiers:
Here, sum, a, b is an identifier.
Keywords:
Here, int is a keyword
Data Type:
Data type of sum, a, b is int
Variable:
Here, sum, a, b are variables.
Expression:
sum = a + b ;