SlideShare a Scribd company logo
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

More Related Content

What's hot

Structure of C program
Structure of C programStructure of C program
Structure of C program
Pavan 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.Sivakumar
Sivakumar R D .
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
MalikaJoya
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
Bharat Kalia
 
Cnotes
CnotesCnotes
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili 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 - JavaTpoint
JavaTpoint.Com
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
Lakshmi Sarvani Videla
 
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
Sachin 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 chart
Prasanna R Kovath
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
nTier Custom Solutions
 
C Programming
C ProgrammingC Programming
C Programming
educationfront
 
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 Jyothi
Sowmya Jyothi
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
Mohamed Elsayed
 

What's hot (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
 

Viewers also liked

What is c
What is cWhat is c
What is c
Nitesh Saitwal
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
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
Anil Dutt
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
Structure in C
Structure in CStructure in C
Structure in C
Fazle Rabbi Ador
 
C material
C materialC material
C material
tarique472
 
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 tutorial
Mayci Neal
 
Scala at Mind Candy
Scala at Mind CandyScala at Mind Candy
Scala at Mind Candy
Mark 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 Report
lelandb01
 
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
 

Viewers also liked (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
 

Similar to 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.pptx
Mugilvannan11
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
vino108206
 
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
GauravRawat830030
 
INTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptxINTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptx
MohammedtajuddinTaju
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
shahidullah57
 
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
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
phanleson
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
farishah
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
Subramanyambharathis
 
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
Batra Centre
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
sidhantkulkarni1
 
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
KirubelWondwoson1
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
valerie5142000
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processor
shindept123
 
Intoduction to c language
Intoduction to c languageIntoduction to c language
Intoduction to c language
Student
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
Mitali Chugh
 
Unit 2 ppt
Unit 2 pptUnit 2 ppt
Unit 2 ppt
Mitali Chugh
 
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
SanketShah544615
 
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
 

Similar to 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
 

More from 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 9
alish 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) - sharifah
alish 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) - sharifah
alish 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_12
alish 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
 

More from 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
 

Recently uploaded

Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 

Recently uploaded (20)

Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 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.