SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Structure of C program
Structure of C programStructure of C program
Structure of C programPavan prasad
 
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.SivakumarSivakumar R D .
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingMalikaJoya
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C BasicsBharat Kalia
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
 
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 - JavaTpointJavaTpoint.Com
 
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 cSachin Kumar
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)ViswanathanS21
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartPrasanna R Kovath
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I vampugani
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C LanguageMohamed Elsayed
 

Was ist angesagt? (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
 

Andere mochten auch

C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSBESTECH 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_outputAnil Dutt
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
インドネシア JCM事業 FS報告会
インドネシア JCM事業 FS報告会インドネシア JCM事業 FS報告会
インドネシア JCM事業 FS報告会Takeshi Mitsuishi
 
Podcast tutorial
Podcast tutorialPodcast tutorial
Podcast tutorialMayci Neal
 
Scala at Mind Candy
Scala at Mind CandyScala at Mind Candy
Scala at Mind CandyMark Baker
 
Recruitment services for it services
Recruitment services for it servicesRecruitment services for it services
Recruitment services for it servicescrescitasolutions
 
Problemas resoltos new
Problemas resoltos newProblemas resoltos new
Problemas resoltos newjuanapardo
 
2012 Salary Report
2012 Salary Report2012 Salary Report
2012 Salary Reportlelandb01
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8alish sha
 
Hospital Experience for Ethnic Minority
Hospital Experience for Ethnic MinorityHospital Experience for Ethnic Minority
Hospital Experience for Ethnic Minoritystoryofxu
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13alish sha
 
綱渡りなEc2運用でコスト削減
綱渡りなEc2運用でコスト削減綱渡りなEc2運用でコスト削減
綱渡りなEc2運用でコスト削減Tomoyuki Tochihira
 
It activity 6.3 catapults
It activity 6.3 catapultsIt activity 6.3 catapults
It activity 6.3 catapultslibbyheli
 

Andere mochten auch (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
 

Ähnlich wie Chap 2 structure of c programming dti2143

C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdfvino108206
 
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 fsfyshuGauravRawat830030
 
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 conceptsssuserf86fba
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionalsphanleson
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c languagefarishah
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
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 CANTTBatra Centre
 
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.pdfKirubelWondwoson1
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processorshindept123
 
Intoduction to c language
Intoduction to c languageIntoduction to c language
Intoduction to c languageStudent
 
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
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer muniryaseen
 

Ähnlich wie 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
 

Mehr von alish sha

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 9alish sha
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)alish sha
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation alish sha
 
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) - sharifahalish sha
 
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) - sharifahalish sha
 
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)alish sha
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13alish sha
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012alish sha
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaboratealish sha
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1alish sha
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12alish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Attn list test
Attn list testAttn list test
Attn list testalish sha
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303alish sha
 
Final project
Final projectFinal project
Final projectalish sha
 

Mehr von 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
 

Kürzlich hochgeladen

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 

Kürzlich hochgeladen (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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
 

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.