SlideShare a Scribd company logo
1 of 32
Computer Science: A Structured Programming Approach Using C 1
Objectives
❏ Compreender a estrutura de um programa em linguagem C.
❏ Escrever seu primeiro programa em C.
❏ Introduzir o comando include pré-processador.
❏ Ser capaz de criar bons identificadores para objetos em um programa.
❏ Ser capaz de listar, descrever e usar os tipos de dados básicos C.
❏ Ser capaz de criar e utilizar variáveis e constantes.
Introdução à linguagem C
Computer Science: A Structured Programming Approach Using C 2
2-1 Introdução
C é uma linguagem de programação estruturada. É
considerada uma linguagem de alto nível porque
permite que o programador se concentre no problema
em questão e não se preocupe com a máquina que o
programa estará usando.
Computer Science: A Structured Programming Approach Using C 3
2-2 C Programs
Structure of a C Program
Your First C Program
Comments
The Greeting Program
Topics discussed in this section:
Computer Science: A Structured Programming Approach Using C 4
FIGURE 2-2 Estrutura de um Programa em C
Computer Science: A Structured Programming Approach Using C 5
FIGURE 2-3 Olá Mundo
Computer Science: A Structured Programming Approach Using C 6
PROGRAM 2-1 The Greeting Program
// Declarações de Variáveis
// Instruções
Computer Science: A Structured Programming Approach Using C 7
FIGURE 2-4 Exemplo de Comentários
// Aqui escrevemos comentários de uma única linha
/*
**Aqui agrupamos comentários que precisam mais de
**Uma linha
*/
Computer Science: A Structured Programming Approach Using C 8
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.
Computer Science: A Structured Programming Approach Using C 9
Table 2-1 Rules for Identifiers
Computer Science: A Structured Programming Approach Using C 10
An identifier must start with a letter or underscore:
it may not have a space or a hyphen.
Note
Computer Science: A Structured Programming Approach Using C 11
C is a case-sensitive language.
Note
Computer Science: A Structured Programming Approach Using C 12
Table 2-2 Examples of Valid and Invalid Names
Computer Science: A Structured Programming Approach Using C 13
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:
Computer Science: A Structured Programming Approach Using C 14
Tabela 2-4 Tipos em C
Tipo Implementação em C
Computer Science: A Structured Programming Approach Using C 15
2-5 Variáveis
Variavel é um nome que definimos para armazenar dados
de forma simples.
Variable Declaration
Variable Initialization
Topics discussed in this section:
Computer Science: A Structured Programming Approach Using C 16
FIGURE 2-11 Variables
Computer Science: A Structured Programming Approach Using C 17
Table 2-5 Examples of Variable Declarations and Definitions
Computer Science: A Structured Programming Approach Using C 18
FIGURE 2-12 Variable Initialization
‘B’
Computer Science: A Structured Programming Approach Using C 19
When a variable is defined, it is not initialized.
We must initialize any variable requiring
prescribed data when the function starts.
Note
Computer Science: A Structured Programming Approach Using C 20
PROGRAM 2-2 Print Sum of Three Numbers
Computer Science: A Structured Programming Approach Using C 21
PROGRAM 2-2 Print Sum of Three Numbers (continued)
Computer Science: A Structured Programming Approach Using C 22
PROGRAM 2-2 Print Sum of Three Numbers (continued)
Computer Science: A Structured Programming Approach Using C 23
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:
Computer Science: A Structured Programming Approach Using C 24
A character constant is enclosed in single quotes.
Note
Computer Science: A Structured Programming Approach Using C 25
Table 2-6 Symbolic Names for Control Characters
Computer Science: A Structured Programming Approach Using C 26
Table 2-7 Examples of Integer Constants
Computer Science: A Structured Programming Approach Using C 27
Table 2-8 Examples of Real Constants
Computer Science: A Structured Programming Approach Using C 28
FIGURE 2-13 Some Strings
Computer Science: A Structured Programming Approach Using C 29
FIGURE 2-14 Null Characters and Null Strings
Computer Science: A Structured Programming Approach Using C 30
Use single quotes for character constants.
Use double quotes for string constants.
Note
Computer Science: A Structured Programming Approach Using C 31
PROGRAM 2-3 Memory Constants
Computer Science: A Structured Programming Approach Using C 32
PROGRAM 2-3 Memory Constants (continued)

More Related Content

Similar to Chap-02-1.ppt

CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt
CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.pptCODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt
CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.pptadamjackson818417
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit orderMalikireddy Bramhananda Reddy
 
Unit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxUnit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxSanketShah544615
 
Chap-14-1 (1).ppt
Chap-14-1 (1).pptChap-14-1 (1).ppt
Chap-14-1 (1).pptOmPrakasDas
 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxravi2692kumar
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manualAnil Bishnoi
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chaptersIbrahim Elewah
 
ch01_an overview of computers and programming languages
ch01_an overview of computers and programming languagesch01_an overview of computers and programming languages
ch01_an overview of computers and programming languagesLiemLe21
 
CHAPTER-2.ppt
CHAPTER-2.pptCHAPTER-2.ppt
CHAPTER-2.pptTekle12
 

Similar to Chap-02-1.ppt (20)

Chapter 02-02.pptx
Chapter 02-02.pptxChapter 02-02.pptx
Chapter 02-02.pptx
 
Variable-intro.pptx
Variable-intro.pptxVariable-intro.pptx
Variable-intro.pptx
 
Intro
IntroIntro
Intro
 
CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt
CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.pptCODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt
CODING-DAY-2-INTRODUCTION TO C PROGRAMMING.ppt
 
Chap 01-1 jwfiles
Chap 01-1 jwfilesChap 01-1 jwfiles
Chap 01-1 jwfiles
 
Chap-07-1.ppt
Chap-07-1.pptChap-07-1.ppt
Chap-07-1.ppt
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
 
Unit 1.1 - Introduction to C.pptx
Unit 1.1 - Introduction to C.pptxUnit 1.1 - Introduction to C.pptx
Unit 1.1 - Introduction to C.pptx
 
Unit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxUnit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptx
 
C AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDYC AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDY
 
Chap-14-1 (1).ppt
Chap-14-1 (1).pptChap-14-1 (1).ppt
Chap-14-1 (1).ppt
 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptx
 
Chap 11-1
Chap 11-1Chap 11-1
Chap 11-1
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chapters
 
ch01_an overview of computers and programming languages
ch01_an overview of computers and programming languagesch01_an overview of computers and programming languages
ch01_an overview of computers and programming languages
 
trial
trialtrial
trial
 
CHAPTER-2.ppt
CHAPTER-2.pptCHAPTER-2.ppt
CHAPTER-2.ppt
 
Session1 c1
Session1 c1Session1 c1
Session1 c1
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Chap-02-1.ppt

  • 1. Computer Science: A Structured Programming Approach Using C 1 Objectives ❏ Compreender a estrutura de um programa em linguagem C. ❏ Escrever seu primeiro programa em C. ❏ Introduzir o comando include pré-processador. ❏ Ser capaz de criar bons identificadores para objetos em um programa. ❏ Ser capaz de listar, descrever e usar os tipos de dados básicos C. ❏ Ser capaz de criar e utilizar variáveis e constantes. Introdução à linguagem C
  • 2. Computer Science: A Structured Programming Approach Using C 2 2-1 Introdução C é uma linguagem de programação estruturada. É considerada uma linguagem de alto nível porque permite que o programador se concentre no problema em questão e não se preocupe com a máquina que o programa estará usando.
  • 3. Computer Science: A Structured Programming Approach Using C 3 2-2 C Programs Structure of a C Program Your First C Program Comments The Greeting Program Topics discussed in this section:
  • 4. Computer Science: A Structured Programming Approach Using C 4 FIGURE 2-2 Estrutura de um Programa em C
  • 5. Computer Science: A Structured Programming Approach Using C 5 FIGURE 2-3 Olá Mundo
  • 6. Computer Science: A Structured Programming Approach Using C 6 PROGRAM 2-1 The Greeting Program // Declarações de Variáveis // Instruções
  • 7. Computer Science: A Structured Programming Approach Using C 7 FIGURE 2-4 Exemplo de Comentários // Aqui escrevemos comentários de uma única linha /* **Aqui agrupamos comentários que precisam mais de **Uma linha */
  • 8. Computer Science: A Structured Programming Approach Using C 8 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.
  • 9. Computer Science: A Structured Programming Approach Using C 9 Table 2-1 Rules for Identifiers
  • 10. Computer Science: A Structured Programming Approach Using C 10 An identifier must start with a letter or underscore: it may not have a space or a hyphen. Note
  • 11. Computer Science: A Structured Programming Approach Using C 11 C is a case-sensitive language. Note
  • 12. Computer Science: A Structured Programming Approach Using C 12 Table 2-2 Examples of Valid and Invalid Names
  • 13. Computer Science: A Structured Programming Approach Using C 13 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:
  • 14. Computer Science: A Structured Programming Approach Using C 14 Tabela 2-4 Tipos em C Tipo Implementação em C
  • 15. Computer Science: A Structured Programming Approach Using C 15 2-5 Variáveis Variavel é um nome que definimos para armazenar dados de forma simples. Variable Declaration Variable Initialization Topics discussed in this section:
  • 16. Computer Science: A Structured Programming Approach Using C 16 FIGURE 2-11 Variables
  • 17. Computer Science: A Structured Programming Approach Using C 17 Table 2-5 Examples of Variable Declarations and Definitions
  • 18. Computer Science: A Structured Programming Approach Using C 18 FIGURE 2-12 Variable Initialization ‘B’
  • 19. Computer Science: A Structured Programming Approach Using C 19 When a variable is defined, it is not initialized. We must initialize any variable requiring prescribed data when the function starts. Note
  • 20. Computer Science: A Structured Programming Approach Using C 20 PROGRAM 2-2 Print Sum of Three Numbers
  • 21. Computer Science: A Structured Programming Approach Using C 21 PROGRAM 2-2 Print Sum of Three Numbers (continued)
  • 22. Computer Science: A Structured Programming Approach Using C 22 PROGRAM 2-2 Print Sum of Three Numbers (continued)
  • 23. Computer Science: A Structured Programming Approach Using C 23 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:
  • 24. Computer Science: A Structured Programming Approach Using C 24 A character constant is enclosed in single quotes. Note
  • 25. Computer Science: A Structured Programming Approach Using C 25 Table 2-6 Symbolic Names for Control Characters
  • 26. Computer Science: A Structured Programming Approach Using C 26 Table 2-7 Examples of Integer Constants
  • 27. Computer Science: A Structured Programming Approach Using C 27 Table 2-8 Examples of Real Constants
  • 28. Computer Science: A Structured Programming Approach Using C 28 FIGURE 2-13 Some Strings
  • 29. Computer Science: A Structured Programming Approach Using C 29 FIGURE 2-14 Null Characters and Null Strings
  • 30. Computer Science: A Structured Programming Approach Using C 30 Use single quotes for character constants. Use double quotes for string constants. Note
  • 31. Computer Science: A Structured Programming Approach Using C 31 PROGRAM 2-3 Memory Constants
  • 32. Computer Science: A Structured Programming Approach Using C 32 PROGRAM 2-3 Memory Constants (continued)