0% found this document useful (0 votes)
52 views59 pages

IT102-LecturePresentation 3

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 59

IT 102 –

COMPUTER
PROGRAMMING 1

C++ Programming Language

Mr. Johnniephere E. Agravante


LMS – Learning Management Systems
a. Edmodo/Google Classroom (Attendance)
b. Google Form (Quizzes, Exams)

Software Requirements:
a. Desktop/Laptop
Download & Install DEV C++ any version
b. Mobile Device
Download & Install CPPDROID APP
CPPDROID – MOBILE APP
CLASS CODE - k4sendi

1 2 3 4 5
WEEK 1 – WEEK 3 TOPICS
• Computer Program and Computer Programming
• Introduction on Computer Programming Language
• C++ Programming Language
• Generations and Types of Programming Language
• Six Stages in Developing Computer Program
• Integrated Development Environment
WEEK 4 – WEEK 8 TOPICS
• C++ Operators
• Base elements of a C++ Program
• Structure of a C++ program
• Variables and Data Types
• Declaration and Initialization of Variable
• Basic Input and Output
WEEK 9 – WEEK 12 TOPICS
• Control Structure 1 – Selection Statement
• If Statement
• If Else If Statement
• Switch Statement
WEEK 13 – WEEK 18 TOPICS
• Control Structure II – Iteration Statement or Looping
Statement
• While Loop Statement
• Do-While Loop Statement
• For Loop Statement
• Flow Chart
• User-Defined Functions
• Arrays
• Final Requirement / Individual Computer Program
DESIRED LEARNING OUTCOMES:

• Define and discuss computer program.


• Define and enumerate programming languages.
• Discuss the advantages and disadvantages of Levels of
Programming language.
PROGRAMMING CONCEPTS
Every computer has to be well planned and executed
correctly. Instructions must be in logical sequence that can be
easily be understood by the computer. The problem must be
analyzed to such a level of detail that all logical conditions may
be encountered during the process are taken into consideration.
Computers as just a tool it does not have its own mind very
dependent to the programmer who gives instructions. Analyze
the problem very well before writing codes using programming
language such as C++/Java.
 
COMPUTER PROGRAM
• A program is a list of instructions written in
a programming language that a computer
can execute so that the machine acts in a
predetermined way.
• Program is synonymous with software. A
program is also a sequence of instructions
that can be executed by a computer. The
term may also refer to the original source
code or to executable (machine language)
version.
WHAT IS COMPUTER
PROGRAMMING?
• It is a process of creating, analysing,
and designing a computer program.
• Computer programming is the process
of designing and building an executable
computer program to accomplish a
specific computing result or to perform
a specific task. 
PROGRAMMING
LANGUAGE/S
• A programming language is an artificial
language designed to communicate
instructions to a machine, particularly a
computer.
• Programming languages can be used to
create programs that control the behavior
of a machine and/or to express
algorithms precisely
• Software used to create another software.
LIST OF A PROGRAMMING
LANGUAGE:
1. Java PL
2. C++ PL
3. Visual Basic.Net
4. SQL
5. iSWIFT
6. HTML
7. C#
8. Visual Basic
9. PHP PL
10.Javascript
11.Python
LIST OF THE BEST PROJECTS DEVELOPED IN
C++

“C++ is a secret weapon of the biggest companies in the world.”


LIST OF THE BEST PROJECTS DEVELOPED IN
JAVA
LIST OF THE BEST PROJECTS (WEBSITES) DEVELOPED
IN PHP
Unity Technologies

Moonton
SAMPLE COMPUTER PROGRAM WRITTEN IN C++
PROGRAMMING LANGUAGE:

# include <iostream>
using namespace std;
int main ()
{
cout<<“Hello World!”;
return 0;
}
THE PROGRAMMER SHOULD TRY TO INCORPORATE
THE FOLLOWING QUALITIES INTO ANY PROGRAM.
1. Program should be easy to read and understandable.
Data names should be descriptive. Statements should be
placed in a format that is easy to read and follow.
Placing enough comments can help in making the
program easier to understand.
2. Programs should be efficient. Programs should execute
in as little time as possible.
3. Programs should be reliable. Programs should consistently
produce the correct output. All formulas and computations, as
well as all logic test and transfer control must be accurate.
4. Programs must be robust. Programs should work under all
conditions. Reliability alone is no guarantee for a successful
program. Internal logic may be correct but incorrect data item
could produce an incorrect data item could produce incorrect
output.
For example, how would a program react if a person’s age is
between 16, 29, or -21? Or instead of accepting numerical
values such as 1, 10, 5, 3 but the person give a letter A?

5. Programs should be maintainable. They should be easy to


update and modify. Programs should be written in
independent modules so that a change in one module does not
mean change of other modules.
WEEK 2 - WEEK 3 LESSONS

• Generations and Types of Programming Language


• Six Stages in Developing Computer Program
• Integrated Development Environment
DESIRED LEARNING OUTCOMES:

• To be able to discuss and introduce the types of


programming language.
• To be able to introduce the generations of programming
language.
• To be able to identify and discuss the stages in developing
computer program.
TYPES OF PROGRAMMING LANGUAGES

• MACHINE LANGUAGE
 It is the only language that the computer understands.
 It only consists of binary numbers 0 and 1.
 The use of binary number as basis of machine language was proposed by
Dr. John Von Neumann.
 Programs written in machine language is very fast in terms of program
execution and uses only minimal amount of computer resources such as
memory, hard drive and CPU but it is not easy to write, debug and test
programs written in machine language on the part of the programmer.
 Machine language is widely used in 1930’s up to early 1950’s primarily
because of the small storage capacity and CPU speed of computer during
that time.
ADVANTAGE OF MACHINE LANGUAGE:

 The only advantage is that program


of machine language run very fast
because no translation program is
required for the CPU.
DISADVANTAGES OF MACHINE LANGUAGE:
• It is very difficult to program in machine language.
The programmer has to know the details of the
computer hardware to write the program.
• The programmer has to remember a lot of codes to
write a program which results in program
errors.
• It is difficult to debug the program.
• It is very difficult to maintain and modify the
program.
• It is designed to work in a particular computer
hardware architecture
• LOW LEVEL PROGRAMMING LANGUAGE
 is also known as assembly language.
 This is a type of low level programming language in which
each program statement corresponds to an instruction that
the microprocessor can carry out.
 After writing an assembly language program, the
programmer must use the assembler specific to the processor
to translate the assembly language into a corresponding
machine code that computers understand. Central Processing
Unit) of the computer.
ADVANTAGES OF LOW
LEVEL LANGUAGES
 It consists of binary digits,
characters and some symbols.
 Very fast program execution
depends on machine.
 Program written in low level
language is called object code.
DISADVANTAGES OF LOW
LEVEL LANGUAGES

 It is not easy to understand.


 It is difficult to modify.
 Program written in low level
language can run only on
specific microprocessor or CPU.
• HIGH LEVEL PROGRAMMING LANGUAGE
 enable the programmer to write programs that are more or less
independent on a particular type of computer.
 are closer to human language that the machine languages the
computer truly understands.
 The main advantage of a high level language over low level
language is that they are easier to understand, modify and
debug.
 allow the programmers to focus on solving the problem rather
than knowing how to program a computer.
ADVANTAGES OF HIGH LEVEL
LANGUAGE:

• It is close to human being.


• It is easy to understand.
• It consists of English language like
structure.
• It does not depend upon machine.
• It is easy to modify.
• The programs written in high level
languages is called source code.
DISADVANTAGES OF HIGH
LEVEL LANGUAGES:
• It needs language translator to translate
into program into machine language.
• Very slow in terms of program
execution compared to machine or
assembly language.
• It needs big amount of system resources such
as memory, disk space and CPU speed
to run the program properly.
• It does not execute directly on
computer.
Figure 1.0

Figure 2.0
Note: High-level languages, such as Swift and C++
must be compiled into machine language before the
code is run on a computer. Since computers are digital
devices, they only recognize binary data.

Swift is a powerful and intuitive programming


language for macOS, iOS, watchOS, tvOS and beyond.
GENERATIONS OF PROGRAMMING LANGUAGE

1. First Generation; Machine Language


2. Second Generation; Assembly Language/Low Level
Language
3. Third Generation; High-Level Language
4. Fourth Generation: Object-Oriented Language
5. Fifth Generation; Logic Programming
FIRST GENERATION (1GL)

• Machine Language
• Uses binary codes that consist of string of only zeroes
and ones
• These are languages that a computer can understand
and execute directly
• Low level language
SECOND GENERATION (2GL)

• Assembly Language
• Instead of zeroes and ones, it uses mnemonics or very
short words for commands
• Program written in assembly language must be converted
by an ASSEMBLER
• Low level language TASM, MASM
THIRD GENERATION (3GL)

• High – level Language


• Can write programs that are more or less independent of a particular
type of computer
• It is considered high-level because they are closer to human languages
and they are easier to read, write, and maintain.
• Uses a COMPUTER to translate the source code into machine
readable code
• FORTRAN, BASIC, COBOL, Pascal. C, C++, Algol , Ada, C#, Java,
JavaScript
FOURTH GENERATION (4GL)

• Object Oriented Programming Language


• Organize coding around objects
• Event driven – event triggers the outcome of the
program
• JAVA, C++, C#, Visual Basic, VB, NET, JavaScript,
Python, Ruby, Scala, PHP
FIFTH GENERATION (5GL)

• Logic Programming – Examples:Prolog, answer set


programming (ASP) and Datalog
• Artificial Language
• Operates on the concept of solving problems based on constraints
or rules that have been declared in the program.
• The focus is on making the computer program solve the problem
for you
• Uses knowledge bases and experts system
Logic programming is a programming paradigm which is largely
based on formal logic. Any program written in a logic programming
language is a set of sentences in logical form, expressing facts and
rules about some problem domain.
• PROLOG, Mercury, LISP
• PROGRAMMING PARADIGMS
• Imperative
• Functional
• Logic
• Object-Oriented
• Concurrent and Distributed
PROGRAMMING LANGUAGES FOR ROBOTICS

• Two main programming languages are the best when used in


robotics: C++ and Python, often used together as each one has
pros and cons. 
• C++ is used in control loops, image processing and to interface
low-level hardware. 
• Python is used to handle high-level behaviors and to quickly
develop tests or proof of concepts.
• ROS (ROBOT OPERATING SYSTEM) is an open-source,
meta-operating system for your robot.
“Programming is 95% self taught! Your professors
just teach you the syntax of a few languages. You
have to prepare yourself for the market by learning
more languages and by practicing them even
more. Programming becomes an addiction if you are
understanding the code and you are going with the
flow.”
SIX STAGES IN DEVELOPING A COMPUTER PROGRAM

1. DEFINING THE PROBLEM


2. DESIGNING A SOLUTION TO THE PROBLEM
3. WRITING THE PROGRAM
4. COMPILING, DEBUGGING AND TESTING THE
PROGRAM
5. DOCUMENTING THE PROGRAM
6. MAINTAINING THE PROGRAM
1. DEFINING THE PROBLEM
• The first step in defining a problem begins with recognizing the need for
information. Information is very important primarily because such
information can help making a good decision. This information may be
request for a solution to a particular problem. The problem is thoroughly
analyzed in order to determine what is required for its solution.
• To better understand and analyze the problem, conduct a study to the nature
of the problem and define what are the necessary code for the program itself.
• The programmer must determine what data are needed, what form they are to
be in, what information should the program be generated, and how the data
are to be manipulated to produce this result.
2. DESIGNING A SOLUTION

• When the problem is defined properly, start designing the


solution to the problem. In designing the solution, breakdown
the problem into several steps so that it is easier to solve the
problem in smaller pieces. This method is called divide and
conquer principle. This sequence of steps for the solution to
the problem is called an Algorithm.
3. WRITING THE PROGRAM

• After the programmer has defined the problem and designed


a solution, the next step is to write the program in a specific
programming language. Although the definition and solution
of the problem are independent of the programming
language, the proposed solution to the problem may limit the
choices of the languages that can be used.
4. COMPILING, DEBUGGING AND TESTING THE
PROGRAM

• The instructions written in a programming language such as


Java must be translated into machine language that is
loaded into the computer when that language is used. It
translates each line code into machine instruction that can
easily be understood by the computer.
5. DOCUMENTATION OF THE PROGRAM

• Certification consist of written descriptions and explanations of


programs and other materials associated with an organization’s
data processing system.
• Documentation of a system and program designs are one of the
most important requirements for success in data processing
application.
• Proper program documentation serves as a guide for programmers
and system analysis who must modify or update the existing
programs and systems procedures.
6. MAINTENANCE
 is one of the most important aspects in developing a computer
program in a sense that there are errors or bugs that are spotted
by the user. It should be fixed as soon as possible in order to
avoid big problems along the way in using the system. Let say
for example, the user has discovered that every time a new
record is being added in the database, the record is not being
saved correctly. Having this problem for example is very critical
in any business organization. This problem should be corrected
right away by the programmer so that it will not hamper the day
operation of the company.
BUGS – IT REFERS TO ERRORS IN A COMPUTER
PROGRAM.

TYPES OF PROGRAMMING ERRORS


 Syntax errors – Errors due to the fact that the syntax of
the language is not respected.

 Semantic errors – Errors due to an improper use of


program statements. 
Logical errors – Errors due to the fact that the
specification is not respected.
Compile time errors – syntax errors and static
semantic errors indicated by the compiler.
Run-time errors – dynamic semantic errors, and
logical errors, that cannot be detected by the
compiler (debugging).
THANK YOU..!
C++ PROGRAMMING LANGUAGE

- (/ˌsiːˌplʌsˈplʌs/) is a general-purpose programming


language created by Bjarne Stroustrup as an extension of
the C programming language, or "C with Classes".
IDE – INTEGRATED DEVELOPMENT ENVIRONMENT

• Dev C++
• Visual Studio Code
• Code:: Blocks
• Eclipse
• CodeLite
• Sublime Text
• NetBeans
• Qt Creator
• Brackets
• Atom
• Borland C++
• CPPDROID – Android Mobile
Device

You might also like