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)

More Related Content

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

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

Recently uploaded (20)

PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Controller Request and Response in Odoo18
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Horarios de distribución de agua en julio
pegazohn1978
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
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).