SlideShare a Scribd company logo
1 of 28
ProgrammingProgramming
FundamentalsFundamentals
Lecture No. 1Lecture No. 1
11
Course ObjectivesCourse Objectives
Objectives of this course are three foldObjectives of this course are three fold
1.1. To appreciate the need for aTo appreciate the need for a
programming languageprogramming language
2.2. To introduce the concept and usabilityTo introduce the concept and usability
of the structured programmingof the structured programming
methodologymethodology
3.3. To develop a useful program for theTo develop a useful program for the
processes that are used in Physicsprocesses that are used in Physics
22
Course ContentsCourse Contents
To achieve our first two objectives weTo achieve our first two objectives we
will be discussingwill be discussing
 Basic Programming constructs andBasic Programming constructs and
building blocksbuilding blocks
 Structured programmingStructured programming
 OOP conceptsOOP concepts
33
Course ContentsCourse Contents
 Introduction to C++Introduction to C++
 Variables and expressionsVariables and expressions
 Control structuresControl structures
– Decision MakingDecision Making
– LoopingLooping
 User Defined FunctionsUser Defined Functions
44
Course ContentsCourse Contents
 Arrays and PointersArrays and Pointers
 Dynamic memory AllocationDynamic memory Allocation
 File handlingFile handling
 Structures and UnionsStructures and Unions
 Object oriented programmingObject oriented programming
ConceptsConcepts
55
ResourcesResources
 Books:Books:
– C++ How to Program by Deitel & DeitelC++ How to Program by Deitel & Deitel
– Let Us C++ by Yashavant KanetkarLet Us C++ by Yashavant Kanetkar
 Slides, Materials from Internet etc.Slides, Materials from Internet etc.
66
Course PolicyCourse Policy
Policy for the distribution of marks andPolicy for the distribution of marks and
examination is as followsexamination is as follows
 Assignments/Quiz 15%Assignments/Quiz 15%
 Midterm 15 %Midterm 15 %
 Final 70%Final 70%
77
Instructor ProfileInstructor Profile
Kamran UllahKamran Ullah
 Lecturer in CS/IT, IBMSLecturer in CS/IT, IBMS
– Since September 2014Since September 2014
 PhD Scholar in Computer SciencePhD Scholar in Computer Science
– From IIUI since Fall 2011From IIUI since Fall 2011
 MS (CS)MS (CS)
– From IIUI in July 2011From IIUI in July 2011
 4½ years teaching experience in4½ years teaching experience in
– Islamic Centre, University of PeshawarIslamic Centre, University of Peshawar
– Iqra National University, PeshawarIqra National University, Peshawar
– IIUI as visiting LecturerIIUI as visiting Lecturer
Computer ProgrammingComputer Programming
and Programmingand Programming
LanguageLanguage
 Writing a code in computer languageWriting a code in computer language
which run again and again to do awhich run again and again to do a
specific task.specific task.
 The term computer language includesThe term computer language includes
a wide variety of languages used toa wide variety of languages used to
communicate with computers (i.e. C+communicate with computers (i.e. C+
+, Java)+, Java)
99
What is a Program?What is a Program?
““A precise sequence of stepsA precise sequence of steps
toto
solve a particular problem”solve a particular problem”
1010
Computers areComputers are
STUPIDSTUPID
1111
HumansHumans areare
even more…….even more…….
1212
Critical SkillsCritical Skills
– AnalysisAnalysis
– Critical ThinkingCritical Thinking
– Attention to DetailAttention to Detail
1313
Design RecipeDesign Recipe
To design a program properly, weTo design a program properly, we
must:must:
– Analyze a problem statement, typicallyAnalyze a problem statement, typically
expressed as a word problemexpressed as a word problem
– Express its essence, abstractly and withExpress its essence, abstractly and with
examplesexamples
– Formulate statements and comments in aFormulate statements and comments in a
precise languageprecise language
– Evaluate and revise the activities in lightEvaluate and revise the activities in light
ofof
1414
Where to write program?Where to write program?
 C++ is a compiler and compile yourC++ is a compiler and compile your
written program forwritten program for
– Checking ErrorsChecking Errors
– Ready to execute on computerReady to execute on computer
 User should be provided a EnvironmentUser should be provided a Environment
(IDE) to write, compile and test the(IDE) to write, compile and test the
programprogram
– i.e: Borland C++, Dev C++, Visual C++i.e: Borland C++, Dev C++, Visual C++
– We will use Visual C++We will use Visual C++ 1515
First Program in C++First Program in C++
1.1. #include <iostream>#include <iostream>
2.2. using namespace std;using namespace std;
3.3. void main()void main()
4.4. {{
5.5. cout<<"In the name of Allah"<<endl;cout<<"In the name of Allah"<<endl;
6.6. cout<<"This is my first Program in C++...";cout<<"This is my first Program in C++...";
7.7. cin.get();cin.get();
8.8. }}
1616
Visual C++ IDEVisual C++ IDE
1717
Program in ExecutionProgram in Execution
(Output)(Output)
1818
Explain the ProgramExplain the Program
(line by line)(line by line)
#include <iostream>#include <iostream>
 ‘‘#’#’ uses for preprocessor directiveuses for preprocessor directive
 HereHere #include#include is used include theis used include the
library function defined inlibrary function defined in iostreamiostream filefile
1919
Explain the ProgramExplain the Program
(line by line)(line by line)
using namespace stdusing namespace std
 Basically, what usingBasically, what using namespacenamespace
stdstd does is to inject all the names of does is to inject all the names of
entities that exist in the stdentities that exist in the std
namespace into the global namespacenamespace into the global namespace
– i.ei.e coutcout andand endlendl
2020
Explain the ProgramExplain the Program
(line by line)(line by line)
void main()void main()
 main()main() is the basic function telling theis the basic function telling the
computer to where the executedcomputer to where the executed
should be started.should be started.
 voidvoid tells the computer that main()tells the computer that main()
function does not return any value.function does not return any value.
2121
Explain the ProgramExplain the Program
(line by line)(line by line)
 {{ is used to start the main function andis used to start the main function and
}} is used to end the main function.is used to end the main function.
Actually it define a block of code.Actually it define a block of code.
 Its mean that execution started in justIts mean that execution started in just
below thebelow the {{ and will remain alive whenand will remain alive when
it it get theit it get the }}
– But: A program has many blocksBut: A program has many blocks
2222
Program with many blocksProgram with many blocks
#include <iostream>#include <iostream>
using namespace std;using namespace std;
void main()void main()
{{
int F;int F;
cout<<“Enter value for F”;cout<<“Enter value for F”; cin>>F;cin>>F;
if(F<0)if(F<0)
{{
cout<<“F must be positive”;cout<<“F must be positive”;
exit(0);exit(0);
}}
cin.get();cin.get();
}}
2323
Explain the ProgramExplain the Program
(line by line)(line by line)
cout<<"In the name of Allah"<<endl;cout<<"In the name of Allah"<<endl;
 cout<<cout<< is used for output a lineis used for output a line
– It may be a STRING directly given or mayIt may be a STRING directly given or may
a variable.a variable.
 endlendl is used to end the line (as weis used to end the line (as we
used ENTER button in MSWord)used ENTER button in MSWord)
2424
Explain the ProgramExplain the Program
(line by line)(line by line)
 cin.get()cin.get() stops the execution of thestops the execution of the
program until the user press theprogram until the user press the
ENTER button from keyboard.ENTER button from keyboard.
 getch()getch() may also be used which ismay also be used which is
used to press any key.used to press any key.
2525
What does Semi-What does Semi-
Colon(;) do?Colon(;) do?
 If you have noticed that there is aIf you have noticed that there is a
semi-colon(;) at the end some of lines.semi-colon(;) at the end some of lines.
 Remember it is a rule that everyRemember it is a rule that every
statement must be end with a semi-statement must be end with a semi-
colon.colon.
2626
 You can write multiple statement in aYou can write multiple statement in a
single line:single line:
cout<<“IIUI”;
cin.get();
==
cout<<“IIUI”; cin.get();
2727
What does Semi-What does Semi-
Colon(;) do?Colon(;) do?
SummarySummary
 Course IntroductionCourse Introduction
 Programming LanguageProgramming Language
 What is a Program?What is a Program?
 Writing a simple Program and Line-by-Writing a simple Program and Line-by-
Line ExplanationLine Explanation
2828

More Related Content

What's hot

Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Languagesatvirsandhu9
 
Binary operator overloading
Binary operator overloadingBinary operator overloading
Binary operator overloadingBalajiGovindan5
 
structured programming
structured programmingstructured programming
structured programmingAhmad54321
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programmingHarshita Yadav
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programmingTarun Sharma
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programAAKASH KUMAR
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constantsvinay arora
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNSU-Biliran Campus
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++Ankur Pandey
 

What's hot (20)

C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Binary operator overloading
Binary operator overloadingBinary operator overloading
Binary operator overloading
 
Modular programming
Modular programmingModular programming
Modular programming
 
structured programming
structured programmingstructured programming
structured programming
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
 
Control statements
Control statementsControl statements
Control statements
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 

Similar to Basic structure of C++ program

Lesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxLesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxNeil Mutia
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
Object oriented slides
Object oriented slidesObject oriented slides
Object oriented slidesahad nadeem
 
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
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++Seble Nigussie
 
Introduction
IntroductionIntroduction
IntroductionKamran
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
Topic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.pptTopic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.pptralph581247
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 

Similar to Basic structure of C++ program (20)

Lesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxLesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptx
 
Introduction to programing languages part 1
Introduction to programing languages   part 1Introduction to programing languages   part 1
Introduction to programing languages part 1
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
Object oriented slides
Object oriented slidesObject oriented slides
Object oriented slides
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
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
 
Unit 2 ppt
Unit 2 pptUnit 2 ppt
Unit 2 ppt
 
Intro1
Intro1Intro1
Intro1
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
Introduction
IntroductionIntroduction
Introduction
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Topic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.pptTopic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.ppt
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
Programming
ProgrammingProgramming
Programming
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 

Recently uploaded

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 

Recently uploaded (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 

Basic structure of C++ program

  • 2. Course ObjectivesCourse Objectives Objectives of this course are three foldObjectives of this course are three fold 1.1. To appreciate the need for aTo appreciate the need for a programming languageprogramming language 2.2. To introduce the concept and usabilityTo introduce the concept and usability of the structured programmingof the structured programming methodologymethodology 3.3. To develop a useful program for theTo develop a useful program for the processes that are used in Physicsprocesses that are used in Physics 22
  • 3. Course ContentsCourse Contents To achieve our first two objectives weTo achieve our first two objectives we will be discussingwill be discussing  Basic Programming constructs andBasic Programming constructs and building blocksbuilding blocks  Structured programmingStructured programming  OOP conceptsOOP concepts 33
  • 4. Course ContentsCourse Contents  Introduction to C++Introduction to C++  Variables and expressionsVariables and expressions  Control structuresControl structures – Decision MakingDecision Making – LoopingLooping  User Defined FunctionsUser Defined Functions 44
  • 5. Course ContentsCourse Contents  Arrays and PointersArrays and Pointers  Dynamic memory AllocationDynamic memory Allocation  File handlingFile handling  Structures and UnionsStructures and Unions  Object oriented programmingObject oriented programming ConceptsConcepts 55
  • 6. ResourcesResources  Books:Books: – C++ How to Program by Deitel & DeitelC++ How to Program by Deitel & Deitel – Let Us C++ by Yashavant KanetkarLet Us C++ by Yashavant Kanetkar  Slides, Materials from Internet etc.Slides, Materials from Internet etc. 66
  • 7. Course PolicyCourse Policy Policy for the distribution of marks andPolicy for the distribution of marks and examination is as followsexamination is as follows  Assignments/Quiz 15%Assignments/Quiz 15%  Midterm 15 %Midterm 15 %  Final 70%Final 70% 77
  • 8. Instructor ProfileInstructor Profile Kamran UllahKamran Ullah  Lecturer in CS/IT, IBMSLecturer in CS/IT, IBMS – Since September 2014Since September 2014  PhD Scholar in Computer SciencePhD Scholar in Computer Science – From IIUI since Fall 2011From IIUI since Fall 2011  MS (CS)MS (CS) – From IIUI in July 2011From IIUI in July 2011  4½ years teaching experience in4½ years teaching experience in – Islamic Centre, University of PeshawarIslamic Centre, University of Peshawar – Iqra National University, PeshawarIqra National University, Peshawar – IIUI as visiting LecturerIIUI as visiting Lecturer
  • 9. Computer ProgrammingComputer Programming and Programmingand Programming LanguageLanguage  Writing a code in computer languageWriting a code in computer language which run again and again to do awhich run again and again to do a specific task.specific task.  The term computer language includesThe term computer language includes a wide variety of languages used toa wide variety of languages used to communicate with computers (i.e. C+communicate with computers (i.e. C+ +, Java)+, Java) 99
  • 10. What is a Program?What is a Program? ““A precise sequence of stepsA precise sequence of steps toto solve a particular problem”solve a particular problem” 1010
  • 13. Critical SkillsCritical Skills – AnalysisAnalysis – Critical ThinkingCritical Thinking – Attention to DetailAttention to Detail 1313
  • 14. Design RecipeDesign Recipe To design a program properly, weTo design a program properly, we must:must: – Analyze a problem statement, typicallyAnalyze a problem statement, typically expressed as a word problemexpressed as a word problem – Express its essence, abstractly and withExpress its essence, abstractly and with examplesexamples – Formulate statements and comments in aFormulate statements and comments in a precise languageprecise language – Evaluate and revise the activities in lightEvaluate and revise the activities in light ofof 1414
  • 15. Where to write program?Where to write program?  C++ is a compiler and compile yourC++ is a compiler and compile your written program forwritten program for – Checking ErrorsChecking Errors – Ready to execute on computerReady to execute on computer  User should be provided a EnvironmentUser should be provided a Environment (IDE) to write, compile and test the(IDE) to write, compile and test the programprogram – i.e: Borland C++, Dev C++, Visual C++i.e: Borland C++, Dev C++, Visual C++ – We will use Visual C++We will use Visual C++ 1515
  • 16. First Program in C++First Program in C++ 1.1. #include <iostream>#include <iostream> 2.2. using namespace std;using namespace std; 3.3. void main()void main() 4.4. {{ 5.5. cout<<"In the name of Allah"<<endl;cout<<"In the name of Allah"<<endl; 6.6. cout<<"This is my first Program in C++...";cout<<"This is my first Program in C++..."; 7.7. cin.get();cin.get(); 8.8. }} 1616
  • 17. Visual C++ IDEVisual C++ IDE 1717
  • 18. Program in ExecutionProgram in Execution (Output)(Output) 1818
  • 19. Explain the ProgramExplain the Program (line by line)(line by line) #include <iostream>#include <iostream>  ‘‘#’#’ uses for preprocessor directiveuses for preprocessor directive  HereHere #include#include is used include theis used include the library function defined inlibrary function defined in iostreamiostream filefile 1919
  • 20. Explain the ProgramExplain the Program (line by line)(line by line) using namespace stdusing namespace std  Basically, what usingBasically, what using namespacenamespace stdstd does is to inject all the names of does is to inject all the names of entities that exist in the stdentities that exist in the std namespace into the global namespacenamespace into the global namespace – i.ei.e coutcout andand endlendl 2020
  • 21. Explain the ProgramExplain the Program (line by line)(line by line) void main()void main()  main()main() is the basic function telling theis the basic function telling the computer to where the executedcomputer to where the executed should be started.should be started.  voidvoid tells the computer that main()tells the computer that main() function does not return any value.function does not return any value. 2121
  • 22. Explain the ProgramExplain the Program (line by line)(line by line)  {{ is used to start the main function andis used to start the main function and }} is used to end the main function.is used to end the main function. Actually it define a block of code.Actually it define a block of code.  Its mean that execution started in justIts mean that execution started in just below thebelow the {{ and will remain alive whenand will remain alive when it it get theit it get the }} – But: A program has many blocksBut: A program has many blocks 2222
  • 23. Program with many blocksProgram with many blocks #include <iostream>#include <iostream> using namespace std;using namespace std; void main()void main() {{ int F;int F; cout<<“Enter value for F”;cout<<“Enter value for F”; cin>>F;cin>>F; if(F<0)if(F<0) {{ cout<<“F must be positive”;cout<<“F must be positive”; exit(0);exit(0); }} cin.get();cin.get(); }} 2323
  • 24. Explain the ProgramExplain the Program (line by line)(line by line) cout<<"In the name of Allah"<<endl;cout<<"In the name of Allah"<<endl;  cout<<cout<< is used for output a lineis used for output a line – It may be a STRING directly given or mayIt may be a STRING directly given or may a variable.a variable.  endlendl is used to end the line (as weis used to end the line (as we used ENTER button in MSWord)used ENTER button in MSWord) 2424
  • 25. Explain the ProgramExplain the Program (line by line)(line by line)  cin.get()cin.get() stops the execution of thestops the execution of the program until the user press theprogram until the user press the ENTER button from keyboard.ENTER button from keyboard.  getch()getch() may also be used which ismay also be used which is used to press any key.used to press any key. 2525
  • 26. What does Semi-What does Semi- Colon(;) do?Colon(;) do?  If you have noticed that there is aIf you have noticed that there is a semi-colon(;) at the end some of lines.semi-colon(;) at the end some of lines.  Remember it is a rule that everyRemember it is a rule that every statement must be end with a semi-statement must be end with a semi- colon.colon. 2626
  • 27.  You can write multiple statement in aYou can write multiple statement in a single line:single line: cout<<“IIUI”; cin.get(); == cout<<“IIUI”; cin.get(); 2727 What does Semi-What does Semi- Colon(;) do?Colon(;) do?
  • 28. SummarySummary  Course IntroductionCourse Introduction  Programming LanguageProgramming Language  What is a Program?What is a Program?  Writing a simple Program and Line-by-Writing a simple Program and Line-by- Line ExplanationLine Explanation 2828