SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Introduction to C Programming
Md. Imran Hossain Showrov (showrovsworld@gmail.com)
6
1
Outline
 The C Character Set
 Identifiers
 Keywords
 Data Types
 Variables
 Expressions
 Statements
 Declarations
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.
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
Writing First Program of C
Format of main() function
Writing First Program of C (cont..)
#include <stdio.h>
main()
{
printf(“Welcome to C programmingn”);
}
Output:
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.
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.
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)
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.
Keywords (cont..)
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
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
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;
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
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;
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];
Example 1
#include<stdio.h>
main()
{
int sum, a =10, b = 20;
sum = a+b;
printf(“%dn”, sum);
}
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 ;
Lecture 6- Intorduction to C Programming

Weitere ähnliche Inhalte

Was ist angesagt?

Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 

Was ist angesagt? (20)

Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
Lecture 14 - Scope Rules
Lecture 14 - Scope RulesLecture 14 - Scope Rules
Lecture 14 - Scope Rules
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
Input And Output
 Input And Output Input And Output
Input And Output
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9
 
What is c
What is cWhat is c
What is c
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
7 functions
7  functions7  functions
7 functions
 
functions in C
functions in Cfunctions in C
functions in C
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
 
C standard library functions
C standard library functionsC standard library functions
C standard library functions
 
C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11
 
[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++
 
Moving Average Filter in C
Moving Average Filter in CMoving Average Filter in C
Moving Average Filter in C
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 

Ähnlich wie Lecture 6- Intorduction to C Programming

3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
ganeshkarthy
 

Ähnlich wie Lecture 6- Intorduction to C Programming (20)

Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
Unit 2- Module 2.pptx
Unit 2- Module 2.pptxUnit 2- Module 2.pptx
Unit 2- Module 2.pptx
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
 
Ch02
Ch02Ch02
Ch02
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
C presentation book
C presentation bookC presentation book
C presentation book
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
C introduction
C introductionC introduction
C introduction
 
C intro
C introC intro
C intro
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
 

Mehr von Md. Imran Hossain Showrov

Mehr von Md. Imran Hossain Showrov (12)

Lecture 22 - Error Handling
Lecture 22 - Error HandlingLecture 22 - Error Handling
Lecture 22 - Error Handling
 
Lecture 21 - Preprocessor and Header File
Lecture 21 - Preprocessor and Header FileLecture 21 - Preprocessor and Header File
Lecture 21 - Preprocessor and Header File
 
Lecture 20 - File Handling
Lecture 20 - File HandlingLecture 20 - File Handling
Lecture 20 - File Handling
 
Lecture 19 - Struct and Union
Lecture 19 - Struct and UnionLecture 19 - Struct and Union
Lecture 19 - Struct and Union
 
Lecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional ArrayLecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional Array
 
Lecture 17 - Strings
Lecture 17 - StringsLecture 17 - Strings
Lecture 17 - Strings
 
Lecture 15 - Array
Lecture 15 - ArrayLecture 15 - Array
Lecture 15 - Array
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
 
Lecture 4- Computer Software and Languages
Lecture 4- Computer Software and LanguagesLecture 4- Computer Software and Languages
Lecture 4- Computer Software and Languages
 
Lecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devicesLecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devices
 
Lecture 2 - Introductory Concepts
Lecture 2 - Introductory ConceptsLecture 2 - Introductory Concepts
Lecture 2 - Introductory Concepts
 
Lecture 1- History of C Programming
Lecture 1- History of C Programming Lecture 1- History of C Programming
Lecture 1- History of C Programming
 

Kürzlich hochgeladen

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Kürzlich hochgeladen (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
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
  • 5. Writing First Program of C Format of main() function
  • 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];
  • 18. Example 1 #include<stdio.h> main() { int sum, a =10, b = 20; sum = a+b; printf(“%dn”, sum); }
  • 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 ;