SlideShare a Scribd company logo
Learn by Doing 1
Objectives
❏ To understand the structure of a C-language program.
❏ To write your first C program.
❏ To introduce the include preprocessor command.
❏ To be able to create good identifiers for objects in a program.
❏ To be able to list, describe, and use the C basic data types.
❏ To be able to create and use variables and constants.
❏ To understand input and output concepts.
❏ To be able to use simple input and output statements.
Day 2
Introduction to the C Language
Learn by Doing 2
2-1 Background
C is a structured programming language. It is
considered a high-level language because it allows the
programmer to concentrate on the problem at hand
and not worry about the machine that the program
will be using. That is another reason why it is used by
software developers whose applications have to run on
many different hardware platforms.
Learn by Doing 3
2-2 C Programs
It's time to write your first C program.
Structure of a C Program
Your First C Program
Comments
The Greeting Program
Topics discussed in this section:
Learn by Doing 4
FIGURE 2-2 Structure of a C Program
Learn by Doing 5
FIGURE 2-3 The Greeting Program
Learn by Doing 6
PROGRAM 2-1 The Greeting Program
Learn by Doing 7
FIGURE 2-4 Examples of Block Comments
Learn by Doing 8
FIGURE 2-5 Examples of Line Comments
9
FIGURE 2-6 Nested Block Comments Are Invalid
10
2-3 Identifiers
One feature present in all computer languages is the
identifier. Identifiers allow us to name data and other
objects in the program. Each identified object in the
computer is stored at a unique address.
11
Table 2-1 Rules for Identifiers
Learn by doing 12
An identifier must start with a letter or underscore:
it may not have a space or a hyphen.
Note
13
C is a case-sensitive language.
Note
14
Table 2-2 Examples of Valid and Invalid Names
Learn by doing 15
2-4 Types
A type defines a set of values and a set of operations
that can be applied on those values.
Void Type
Integral Type
Floating-Point Types
Topics discussed in this section:
16
FIGURE 2-7 Data Types
17
FIGURE 2-8 Character Types
18
FIGURE 2-9 Integer Types
19
sizeof (short) ≤ sizeof (int) ≤ sizeof (long) ≤ sizeof (long long)
Note
20
Table 2-3 Typical Integer Sizes and Values for Signed Integers
21
FIGURE 2-10 Floating-point Types
Learn by doing 22
sizeof (float) ≤ sizeof (double) ≤ sizeof (long double)
Note
23
Table 2-4 Type Summary
24
2-5 Variables
Variables are named memory locations that have a type,
such as integer or character, which is inherited from
their type. The type determines the values that a variable
may contain and the operations that may be used with
its values.
Variable Declaration
Variable Initialization
Topics discussed in this section:
25
FIGURE 2-11 Variables
26
Table 2-5 Examples of Variable Declarations and Definitions
27
FIGURE 2-12 Variable Initialization
‘B’
28
When a variable is defined, it is not initialized.
We must initialize any variable requiring
prescribed data when the function starts.
Note
Learn by doing 29
PROGRAM 2-2 Print Sum of Three Numbers
30
PROGRAM 2-2 Print Sum of Three Numbers (continued)
31
PROGRAM 2-2 Print Sum of Three Numbers (continued)
32
2-6 Constants
Constants are data values that cannot be changed
during the execution of a program. Like variables,
constants have a type. In this section, we discuss
Boolean, character, integer, real, complex, and string
constants.
Constant Representation
Coding Constants
Topics discussed in this section:
33
A character constant is enclosed in single quotes.
Note
Learn by doing 34
Table 2-6 Symbolic Names for Control Characters
35
Table 2-7 Examples of Integer Constants
36
Table 2-8 Examples of Real Constants
37
FIGURE 2-13 Some Strings
Learn by doing 38
FIGURE 2-14 Null Characters and Null Strings
39
Use single quotes for character constants.
Use double quotes for string constants.
Note
40
PROGRAM 2-3 Memory Constants
Learn by doing 41
PROGRAM 2-3 Memory Constants (continued)
Ad

Recommended

C.ppt
C.ppt
ShajiAvaroth1
 
Introduction_to_c_programming.ppt for software developing students
Introduction_to_c_programming.ppt for software developing students
Asfiya14
 
C Programming language basic for students
C Programming language basic for students
MohammedRizwanSharie
 
Semester-1-22-23-Introduction_to_c_programming.ppt
Semester-1-22-23-Introduction_to_c_programming.ppt
ChetanChauhan203001
 
1.Introduction_to_c_programming lan.ppt
1.Introduction_to_c_programming lan.ppt
anithachristopher3
 
C Programming Intro.ppt
C Programming Intro.ppt
LECO9
 
SHIVAM.ppt training report presentations
SHIVAM.ppt training report presentations
96dp5cvgx5
 
Aniket tore
Aniket tore
anikettore1
 
unit2.pptx
unit2.pptx
sscprep9
 
C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
ComedyTechnology
 
C notes
C notes
Raunak Sodhi
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
Intro
Intro
CGC Technical campus,Mohali
 
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
history of c.ppt
history of c.ppt
arpanabharani
 
Best_of_438343817-A-PPT-on-C-language.pptx
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
C Program basic concepts using c knoweledge
C Program basic concepts using c knoweledge
priankarr1
 
Introduction to C
Introduction to C
Janani Satheshkumar
 
Lecture 01 2017
Lecture 01 2017
Jesmin Akhter
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
C language ppt
C language ppt
Ğäùråv Júñêjå
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
Variables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
Chapter02.PPT
Chapter02.PPT
Chaitanya Jambotkar
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
introduction2_programming slides briefly exolained
introduction2_programming slides briefly exolained
RumaSinha8
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 

More Related Content

Similar to CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt (20)

unit2.pptx
unit2.pptx
sscprep9
 
C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
ComedyTechnology
 
C notes
C notes
Raunak Sodhi
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
Intro
Intro
CGC Technical campus,Mohali
 
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
history of c.ppt
history of c.ppt
arpanabharani
 
Best_of_438343817-A-PPT-on-C-language.pptx
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
C Program basic concepts using c knoweledge
C Program basic concepts using c knoweledge
priankarr1
 
Introduction to C
Introduction to C
Janani Satheshkumar
 
Lecture 01 2017
Lecture 01 2017
Jesmin Akhter
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
C language ppt
C language ppt
Ğäùråv Júñêjå
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
Variables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
Chapter02.PPT
Chapter02.PPT
Chaitanya Jambotkar
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
introduction2_programming slides briefly exolained
introduction2_programming slides briefly exolained
RumaSinha8
 
unit2.pptx
unit2.pptx
sscprep9
 
C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
ComedyTechnology
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
Best_of_438343817-A-PPT-on-C-language.pptx
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
C Program basic concepts using c knoweledge
C Program basic concepts using c knoweledge
priankarr1
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
Variables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
introduction2_programming slides briefly exolained
introduction2_programming slides briefly exolained
RumaSinha8
 

Recently uploaded (20)

Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Peer Teaching Observations During School Internship
Peer Teaching Observations During School Internship
AjayaMohanty7
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
How to use search fetch method in Odoo 18
How to use search fetch method in Odoo 18
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Peer Teaching Observations During School Internship
Peer Teaching Observations During School Internship
AjayaMohanty7
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
How to use search fetch method in Odoo 18
How to use search fetch method in Odoo 18
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Ad

CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt

  • 1. Learn by Doing 1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C program. ❏ To introduce the include preprocessor command. ❏ To be able to create good identifiers for objects in a program. ❏ To be able to list, describe, and use the C basic data types. ❏ To be able to create and use variables and constants. ❏ To understand input and output concepts. ❏ To be able to use simple input and output statements. Day 2 Introduction to the C Language
  • 2. Learn by Doing 2 2-1 Background C is a structured programming language. It is considered a high-level language because it allows the programmer to concentrate on the problem at hand and not worry about the machine that the program will be using. That is another reason why it is used by software developers whose applications have to run on many different hardware platforms.
  • 3. Learn by Doing 3 2-2 C Programs It's time to write your first C program. Structure of a C Program Your First C Program Comments The Greeting Program Topics discussed in this section:
  • 4. Learn by Doing 4 FIGURE 2-2 Structure of a C Program
  • 5. Learn by Doing 5 FIGURE 2-3 The Greeting Program
  • 6. Learn by Doing 6 PROGRAM 2-1 The Greeting Program
  • 7. Learn by Doing 7 FIGURE 2-4 Examples of Block Comments
  • 8. Learn by Doing 8 FIGURE 2-5 Examples of Line Comments
  • 9. 9 FIGURE 2-6 Nested Block Comments Are Invalid
  • 10. 10 2-3 Identifiers One feature present in all computer languages is the identifier. Identifiers allow us to name data and other objects in the program. Each identified object in the computer is stored at a unique address.
  • 11. 11 Table 2-1 Rules for Identifiers
  • 12. Learn by doing 12 An identifier must start with a letter or underscore: it may not have a space or a hyphen. Note
  • 13. 13 C is a case-sensitive language. Note
  • 14. 14 Table 2-2 Examples of Valid and Invalid Names
  • 15. Learn by doing 15 2-4 Types A type defines a set of values and a set of operations that can be applied on those values. Void Type Integral Type Floating-Point Types Topics discussed in this section:
  • 19. 19 sizeof (short) ≤ sizeof (int) ≤ sizeof (long) ≤ sizeof (long long) Note
  • 20. 20 Table 2-3 Typical Integer Sizes and Values for Signed Integers
  • 22. Learn by doing 22 sizeof (float) ≤ sizeof (double) ≤ sizeof (long double) Note
  • 23. 23 Table 2-4 Type Summary
  • 24. 24 2-5 Variables Variables are named memory locations that have a type, such as integer or character, which is inherited from their type. The type determines the values that a variable may contain and the operations that may be used with its values. Variable Declaration Variable Initialization Topics discussed in this section:
  • 26. 26 Table 2-5 Examples of Variable Declarations and Definitions
  • 27. 27 FIGURE 2-12 Variable Initialization ‘B’
  • 28. 28 When a variable is defined, it is not initialized. We must initialize any variable requiring prescribed data when the function starts. Note
  • 29. Learn by doing 29 PROGRAM 2-2 Print Sum of Three Numbers
  • 30. 30 PROGRAM 2-2 Print Sum of Three Numbers (continued)
  • 31. 31 PROGRAM 2-2 Print Sum of Three Numbers (continued)
  • 32. 32 2-6 Constants Constants are data values that cannot be changed during the execution of a program. Like variables, constants have a type. In this section, we discuss Boolean, character, integer, real, complex, and string constants. Constant Representation Coding Constants Topics discussed in this section:
  • 33. 33 A character constant is enclosed in single quotes. Note
  • 34. Learn by doing 34 Table 2-6 Symbolic Names for Control Characters
  • 35. 35 Table 2-7 Examples of Integer Constants
  • 36. 36 Table 2-8 Examples of Real Constants
  • 38. Learn by doing 38 FIGURE 2-14 Null Characters and Null Strings
  • 39. 39 Use single quotes for character constants. Use double quotes for string constants. Note
  • 41. Learn by doing 41 PROGRAM 2-3 Memory Constants (continued)

Editor's Notes

  • #3: Developed early 1970’s
  • #18: wchar_t is a wide character:  The increased datatype size allows for the use of larger coded character sets. Width is compiler specific (not portable).