SlideShare une entreprise Scribd logo
1  sur  60
Faculty of Mechanical and Manufacturing  Chapter 2 Basic Structure of Programming Prepared by  Alish Ahmad Al-shahab alishahmad.alshahab@gmail.com
Learning Objectives: ,[object Object]
Write a computer program using C programming language.
Convert algorithm into computer program.,[object Object]
Involves translating high-level language (programming language such as C,C++, Visual Basic, C#) Because computers do NOT  understand high level language! Translated to Computer's machine language 00011101 01010101 11011111
Program Development Environment Typical program development environment consist of  six phases to be executed. Edit/Write Preprocess Compile Link Load Execute
Program Development Environment 1. Creating a Program ,[object Object]
Makes corrections if necessary
Saves or stores program on disk 	such as C:       or A:etc. Editor or text editor is a type of program used for editing plain text files. E.gdev/turbo
Program Development Environment Example of text editor Turbo C editor (free)
Program Development Environment Example of text editor DEV C++ (free)
Program Development Environment 2. Preprocessing ,[object Object]
Preprocessor program executes automatically	and process the program code. ,[object Object],	preprocessor directives. ,[object Object],[object Object]
Program Development Environment 3.Compiling a Program ,[object Object],	process into machine code is successful. ,[object Object],	in the compiling dialogue box. ,[object Object]
The process of correcting errors is called debugging.,[object Object]
A linker will creates an executable file and stores it on disk	if the program compiles and links correctly. ,[object Object],	extension depending on type of programming language 	used.
Program Development Environment 5. Loading ,[object Object],	be placed in memory. ,[object Object],	memory. ,[object Object],	the program are also loaded.
Program Development Environment 6. Executing ,[object Object]
Results or output will be displayed.,[object Object]
Program Development Environment Common Programming Errors Error (bugs) Run-time Errors Syntax Errors Logic Errors
Program Development Environment Common Programming Errors Syntax Error 1 Error occurred during compilation normally due to syntax problem Example: ,[object Object]
 Declaration syntax error
 Undefined symbol ‘_main’ in module.
 Statement missing in function main(),[object Object]
Not detected during compilation.,[object Object]
Program Development Environment Common Programming Errors Run-time Error 3 ,[object Object]
User’s mistake.
System would either display alert message   or hang.,[object Object]
Program Development Environment Preprocessor Directive ,[object Object],      program code. ,[object Object]
Must be started with the symbol #, otherwise syntax errors	will be occurred. ,[object Object],#define.
Program Development Environment Preprocessor Directive Format:    #include  <header file> or #include “user defined files” Example #include <stdio.h> #include <conio.h> #include “jam.h”
Program Development Environment Preprocessor Directive Example: Called from standard library #include <stdio.h> ,[object Object]
Lines beginning with # are processed by the preprocessor	before the program is compiled. ,[object Object],	contents of   stdio.h ( standard input/output header)
Program Development Environment ,[object Object],Standard  Library ,[object Object]
Function will be called  and linked to program   via header file
Program Development Environment ,[object Object],User-defined Library ,[object Object],List of header file and its function
Program Development Environment Preprocessor Directive Format:  #define “file name” or #define constant_nameconstant_value Example #define MAX 100
Program Development Environment Program body ,[object Object],	execute. ,[object Object]
Use { to start the program code and } to end the 	program code. Format :    main function    {  //identifiers    //C statements   }
Basic Syntax of Programming Main Function void main( ) { …………..} Main function int main( ) {    return 0; } main( ) {    return 0; }
Program Development Environment Write the most basic structures of  C programming. #include <stdio.h> void main() { }
Program Development Environment C Statement ,[object Object]
Every statements must be ended with semicolonDeclaration statement Function statement Types Control statement Input/Output statement Compound statement
Program Development Environment Comment ,[object Object]
Differs in terms of colour : greyTo increase program readability To document a program Function As a future references To provide additional information
Program Development Environment Using references from any C book, find and study the following concepts (definition and examples):   Reserved Word  Variable  Constant
Program Development Environment Reserved Word ,[object Object]
Contain special meaning understood by compilerRules Case –sensitive Must be written in small case Cannot be used as identifier or  variables
Program Development Environment Reserved Word Example: int The acronym for integer void Refer to the function that will not return any value case    default    switch    break for       continue     float   double return  while   if   do  int
Program Development Environment Identifier ,[object Object]
Store values to be used in programming
Refers to the storage in computerType Standard  identifier User-defined identifier
Program Development Environment Identifier ,[object Object]
Referred asfunction name  which will called from C library Standard identifier printf()   scanf() puts()       gets()
Program Development Environment Identifier ,[object Object],  data to be used in program  ,[object Object]
Store data values/result/outputUser-defined identifier Type Constant Variable
Program Development Environment Identifier User-defined identifier RULES ,[object Object]
Identifiers name cannot be started with numbers
Symbol cannot be used in identifier name
Cannot contains spaces between two identifiers name

Contenu connexe

Tendances

Tendances (20)

Structure of C program
Structure of C programStructure of C program
Structure of C program
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
Cnotes
CnotesCnotes
Cnotes
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 
C programming part1
C programming part1C programming part1
C programming part1
 
Sachin kumar ppt on programming in c
Sachin kumar ppt on programming in cSachin kumar ppt on programming in c
Sachin kumar ppt on programming in c
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
C Programming
C ProgrammingC Programming
C Programming
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 

En vedette

Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
Anil Dutt
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
Recruitment services for it services
Recruitment services for it servicesRecruitment services for it services
Recruitment services for it services
crescitasolutions
 
Problemas resoltos new
Problemas resoltos newProblemas resoltos new
Problemas resoltos new
juanapardo
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
alish sha
 
Hospital Experience for Ethnic Minority
Hospital Experience for Ethnic MinorityHospital Experience for Ethnic Minority
Hospital Experience for Ethnic Minority
storyofxu
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
alish sha
 
It activity 6.3 catapults
It activity 6.3 catapultsIt activity 6.3 catapults
It activity 6.3 catapults
libbyheli
 

En vedette (20)

What is c
What is cWhat is c
What is c
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Structure in C
Structure in CStructure in C
Structure in C
 
C material
C materialC material
C material
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
インドネシア JCM事業 FS報告会
インドネシア JCM事業 FS報告会インドネシア JCM事業 FS報告会
インドネシア JCM事業 FS報告会
 
Podcast tutorial
Podcast tutorialPodcast tutorial
Podcast tutorial
 
Scala at Mind Candy
Scala at Mind CandyScala at Mind Candy
Scala at Mind Candy
 
Recruitment services for it services
Recruitment services for it servicesRecruitment services for it services
Recruitment services for it services
 
Apuntes
Apuntes Apuntes
Apuntes
 
Problemas resoltos new
Problemas resoltos newProblemas resoltos new
Problemas resoltos new
 
2012 Salary Report
2012 Salary Report2012 Salary Report
2012 Salary Report
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Hospital Experience for Ethnic Minority
Hospital Experience for Ethnic MinorityHospital Experience for Ethnic Minority
Hospital Experience for Ethnic Minority
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
綱渡りなEc2運用でコスト削減
綱渡りなEc2運用でコスト削減綱渡りなEc2運用でコスト削減
綱渡りなEc2運用でコスト削減
 
It activity 6.3 catapults
It activity 6.3 catapultsIt activity 6.3 catapults
It activity 6.3 catapults
 

Similaire à Chap 2 structure of c programming dti2143

Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
ssuserf86fba
 

Similaire à Chap 2 structure of c programming dti2143 (20)

C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshuunit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
 
INTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptxINTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptx
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdf
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processor
 
Intoduction to c language
Intoduction to c languageIntoduction to c language
Intoduction to c language
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
 
Unit 2 ppt
Unit 2 pptUnit 2 ppt
Unit 2 ppt
 
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
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
 

Plus de alish sha

Plus de alish sha (20)

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifah
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Lab 6
Lab 6Lab 6
Lab 6
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Attn list test
Attn list testAttn list test
Attn list test
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
 
Final project
Final projectFinal project
Final project
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Chap 2 structure of c programming dti2143

  • 1. Faculty of Mechanical and Manufacturing Chapter 2 Basic Structure of Programming Prepared by Alish Ahmad Al-shahab alishahmad.alshahab@gmail.com
  • 2.
  • 3. Write a computer program using C programming language.
  • 4.
  • 5. Involves translating high-level language (programming language such as C,C++, Visual Basic, C#) Because computers do NOT understand high level language! Translated to Computer's machine language 00011101 01010101 11011111
  • 6. Program Development Environment Typical program development environment consist of six phases to be executed. Edit/Write Preprocess Compile Link Load Execute
  • 7.
  • 9. Saves or stores program on disk such as C: or A:etc. Editor or text editor is a type of program used for editing plain text files. E.gdev/turbo
  • 10. Program Development Environment Example of text editor Turbo C editor (free)
  • 11. Program Development Environment Example of text editor DEV C++ (free)
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20. Program Development Environment Common Programming Errors Error (bugs) Run-time Errors Syntax Errors Logic Errors
  • 21.
  • 23. Undefined symbol ‘_main’ in module.
  • 24.
  • 25.
  • 26.
  • 28.
  • 29.
  • 30.
  • 31. Program Development Environment Preprocessor Directive Format: #include <header file> or #include “user defined files” Example #include <stdio.h> #include <conio.h> #include “jam.h”
  • 32.
  • 33.
  • 34.
  • 35. Function will be called and linked to program via header file
  • 36.
  • 37. Program Development Environment Preprocessor Directive Format: #define “file name” or #define constant_nameconstant_value Example #define MAX 100
  • 38.
  • 39. Use { to start the program code and } to end the program code. Format : main function { //identifiers //C statements }
  • 40. Basic Syntax of Programming Main Function void main( ) { …………..} Main function int main( ) { return 0; } main( ) { return 0; }
  • 41. Program Development Environment Write the most basic structures of C programming. #include <stdio.h> void main() { }
  • 42.
  • 43. Every statements must be ended with semicolonDeclaration statement Function statement Types Control statement Input/Output statement Compound statement
  • 44.
  • 45. Differs in terms of colour : greyTo increase program readability To document a program Function As a future references To provide additional information
  • 46. Program Development Environment Using references from any C book, find and study the following concepts (definition and examples): Reserved Word Variable Constant
  • 47.
  • 48. Contain special meaning understood by compilerRules Case –sensitive Must be written in small case Cannot be used as identifier or variables
  • 49. Program Development Environment Reserved Word Example: int The acronym for integer void Refer to the function that will not return any value case default switch break for continue float double return while if do int
  • 50.
  • 51. Store values to be used in programming
  • 52. Refers to the storage in computerType Standard identifier User-defined identifier
  • 53.
  • 54. Referred asfunction name which will called from C library Standard identifier printf() scanf() puts() gets()
  • 55.
  • 56. Store data values/result/outputUser-defined identifier Type Constant Variable
  • 57.
  • 58. Identifiers name cannot be started with numbers
  • 59. Symbol cannot be used in identifier name
  • 60. Cannot contains spaces between two identifiers name
  • 62.
  • 63.
  • 64.
  • 65. Program Development Environment 1 Declaration format: const data_type const_name = const_value; Data type const float pi = 3.142; Reserved word Constant Value Constant name
  • 66. Program Development Environment 2 Declaration format: #define const_name const_value; Constant value #define pi 3.142; Reserved word Constant name
  • 67. Program Development Environment Example of constant: #define minimum 0; #define MAX 100; const int counter = 100; const char alphabet = ‘J’; const float value = 4.5;
  • 68.
  • 69. Program Development Environment Declaration Example Declaration of a variable number of integer data type. int number; float weight; char alphabet; Declaration of a variable weight of floating point data type. Declaration of a variable alphabet of character data type.
  • 70. Program Development Environment Variable/constant declaration example //Variable and constant declration #include <stdio.h> int number; float weight; void main() { const float pi =3.142; int bilangan; float berat; char abjad; } Variable declaration Constant declaration Variable declaration
  • 71. Program Development Environment Variable and constant declaration example: //Variable and constant declaration #include <stdio.h> const float pi=3.142; void main() { int bilangan, bil, bilang; float berat, kg; char A; }
  • 72.
  • 73.
  • 74.
  • 75. Types of data to be stored and used in programming should be informed to the compiler/system Types Integer Character Floating point
  • 76.
  • 77. Reserved word for integer – int
  • 78. Valid until 5 places of integer number.Integer Example: age is used to represent the age of students between 18 and 25 years old. The declaration for the variable is as follow:int age;
  • 79.
  • 80. Reserved word– double /floatExample: height is used to represent the student’s height between 150 cm and 180 cm. The declaration for the variable is as follow: float height;
  • 81.
  • 82. Reserved word – charCharacter Example: gender is used to represent the gender of a student. The declaration for the variable is as follow: char gender;
  • 83. Program Development Environment Exercise: Determine whether the following identifiers is valid or invalid. Give reason for invalid cases. 1)Parit Raja 2) 20thCentury 3) int 4) INTEGER 5) _BMW2003 6) Reservedword 7) BIT1033 8) markah_pelajar 9) jam*kredit 10) printf
  • 84. Program Development Environment Exercise: Write a suitable variable declaration for each of the following statement: i. Salary of an employee ii. Student’s mark for programming subject iii. ATM pin number iv. Phone number v. Price of one item vi. Bus seat number vii. Student name
  • 85. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: Given the value of x is 10 and a is 12, find the result of the following equation: y = 2x + a - 6
  • 86. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: MrsLeeya needs to determine her students grade for programming subject based on the mark scored during final examination. The ‘A’ grade will be given if the Mark scored is between 85 to 100. If a student has scored 90 marks, what is the grade should MrsLeeya give to the student?
  • 87. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: A box has height, width and length. Calculate the volume of a box.
  • 88. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: Uncle Degawan wants to buy 5 tins of paint from Cinda’s shop. The price of each tin of the paint is RM 15.60. Calculate the price which Uncle Degawan have to pay for all the tin of paints he bought.