SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)SURBHI SAROHA
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)SURBHI SAROHA
 
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 FunctionsDhivyaSubramaniyam
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9Rumman Ansari
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c languageMomenMostafa
 
C standard library functions
C standard library functionsC standard library functions
C standard library functionsVaishnavee Sharma
 
C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11Rumman Ansari
 
[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++Muhammad Hammad Waseem
 
Moving Average Filter in C
Moving Average Filter in CMoving Average Filter in C
Moving Average Filter in CColin
 
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
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 

Tendances (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
 

Similaire à Lecture 6- Intorduction to C Programming

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 languageRai University
 
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 languageRai University
 
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 languageRai University
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
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 languageRai University
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptxmadhurij54
 
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.pptxganeshkarthy
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computerShankar Gangaju
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c programAlamgir Hossain
 

Similaire à 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
 

Plus de 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
 

Dernier

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
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.pptxDenish Jangid
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
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 17Celine George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 

Dernier (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
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
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
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
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
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
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

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 ;