0% found this document useful (0 votes)
11 views32 pages

Introduction to Programming Basics

The document provides an introduction to programming, detailing the evolution of computer languages from machine languages to high-level languages. It discusses the advantages and disadvantages of each language type, as well as programming methodologies like structured and object-oriented programming. Additionally, it covers the basics of C++ programming, including functions, comments, identifiers, reserved words, and the use of whitespace.

Uploaded by

japhetjoakim02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views32 pages

Introduction to Programming Basics

The document provides an introduction to programming, detailing the evolution of computer languages from machine languages to high-level languages. It discusses the advantages and disadvantages of each language type, as well as programming methodologies like structured and object-oriented programming. Additionally, it covers the basics of C++ programming, including functions, comments, identifiers, reserved words, and the use of whitespace.

Uploaded by

japhetjoakim02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Programming Principles

Lecture 1 - Introduction

Mr. Daniel G.
Introduction to Programming
 Programming is a process of planning and
creating a program.

 A computer program, or a program, is a


sequence of statements whose objective is to
accomplish a task.

 Programmers/software developers create


software with the help of powerful tools called
programming languages.
COMPUTER LANGUAGES
 To write a program for a computer, we must
use a computer language. Over the years
computer languages have evolved from
machine languages to natural languages.
 The following is the summary of computer
languages

 1940‘s -- Machine Languages

 1950‘s -- Symbolic Languages

 1960‘s -- High Level Languages


Machine Language
 In the earliest days of computers, the only
programming languages available were machine
languages. Each computer has its own machine
language which is made of streams of 0‘s and 1‘s.
 The instructions in machine language must be in
streams of 0‘s and 1‘s. This is also referred as binary
digits. These are so named as the machine can
directly understood the programs
 Advantages:
 1) High speed execution
 2) The computer can understood instructions
immediately
 3) No translation is needed
Machine Language
 Disadvantages:
 1) Machine dependent
 2) Programming is very difficult
 3) Difficult to understand
 4) Difficult to write bug free programs
 5) Difficult to isolate an error
Example Addition of two numbers
Symbolic Languages (or) Assembly
Language
 An assembly language is a low-level programming
language designed for a specific type of processor. OR a
programming language that consists of instructions that
are mnemonic codes for corresponding machine
language instructions
 These early programming languages simply mirrored
the machine languages using symbols or mnemonics to
represent the various language instructions. These
languages were known as symbolic languages. Because
a computer does not understand symbolic language it
must be translated into the machine language.
 A special program called an Assembler translates
symbolic code into the machine language. Hence they
are called as Assembly language.
Advantages:

 1) Easy to understand and use


 2) Easy to modify and isolate error
 3) High efficiency(Execution)
 4) More control on hardware
Disadvantages:

 1) Machine Dependent Language


 2) Requires translator
 3) Difficult to learn and write programs
 4) Slow development time
High-Level Languages
 High-level languages are portable to many
different computer allowing the programmer to
concentrate on the application problem at hand
rather than the intricacies of the computer.
 High level language in programming is a
language which is easily understand or
interpreted by programmers, Below are the few
characteristics of High level programming
language.
 It can run on any platform
 It needs compiler or Interpreter for translation.
Task
 Read advantages and disadvantages of high level
programming languages
Difference between Machine, Assembly,
High Level Languages
Language Translators
 These are the programs which are used for converting
the programs in one language into machine language
instructions, so that they can be executed by the
computer.
 1) Compiler: It is a program which is used to convert
the high level language programs into machine language
 2) Assembler: It is a program which is used to convert
the assembly level language programs into machine
language
 3) Interpreter: It is a program, it takes one statement
of a high level language program, translates it into
machine language instruction and then immediately
executes the resulting machine language instruction and
so on.
Programming Methodologies
 Approaches to programming design are
 structured approach
 object-oriented approach

Structured Programming
 In this approach, a problem is divided into
smaller sub problems.
 Each sub problem is then analyzed, and a
solution is obtained to solve the sub problem.
 The solutions to all of the sub problems are
then combined to solve the overall problem.
 1. Sequence
 Example: Baking Bread
 Add flour.
Add salt.
Add yeast.
Mix.
Add water.
Knead.
Let rise.
Bake.
Programming Methodologies…
Object-Oriented Programming
 In this approach, the first step in the problem-
solving process is to identify the components
called objects, which form the basis of the
solution.

 The second step is to determine how these


objects interact with one another.
 For example, suppose you want to write a program
that automates the video rental process for a local
video store.
 The two main objects in this problem are the video
and the customer.
Programming Methodologies…
Object-Oriented Programming
 The next step is to specify for each object the
relevant data and possible operations to be
performed on that data.

 For example, for a video object, the data might


include:
 movie name
 starring actors
 producer
 production company
 number of copies in stock
Programming Methodologies…
Object-Oriented Programming
 The next step is to specify for each object the
relevant data and possible operations to be
performed on that data.

 Some of the operations on a video object might include:


 checking the name of the movie
 reducing the number of copies in stock by one after a copy is
rented
 incrementing the number of copies in stock by one after a
customer returns a particular video

 The final program is a collection of interacting


objects.
Basics of a C++
main function
 A function is a collection of statements, and
when it is activated, or executed, it
accomplishes something.

 Every C++ program has a function called


main.
Basics of a C++
Comments
 They are used to describe what a program or a
certain portion of code does.
 During compilation, they are ignored by the
compiler.
 They are two types of comments.
 Line comments (//)
 The compiler ignores all the texts preceded by // in a single line.
 Paragraph comments (/* some texts */)
 The texts are enclosed between /* and */, the compiler ignores
all the texts found between /* and */.
 Example of a paragraph comment.
/* This application prints
Welcome to C++! */
Basics of a C++
Identifiers
 Identifiers are names of things that appear in
programs, such as variables, constants, and
functions.

 A C++ identifier consists of letters, digits, and the


underscore character (_) and must begin with a
letter or underscore.

 C++ is case sensitive - uppercase and lowercase


letters are considered different.
 Thus, the identifier NUMBER is not the same as the
identifier number.
Basics of a C++
Identifiers
 Examples of legal identifiers
 first
 conversion
 payRate
 Counter2
Basics of a C++
Identifiers
 Examples of illegal identifiers
Basics of a C++
Reserved words/keywords
Words that have a specific meaning to the
compiler and they can not be used for other
purposes in the program.

Reserved words include the following.


 int, float, double, char, const, void, return
Basics of a C++
Whitespaces
 Whitespaces are used to separate special
symbols, reserved words, and identifiers.

 Whitespaces include blanks, tabs, and newline


characters.

 Proper utilization of whitespaces in a program


is important.
 They can be used to make the program more
readable.
 #include <iostream>
 int main() {

 std::cout << "I like cake!";
 std::cout << "it's really sweet1!";
return 0;
 }
 #include <iostream>
 it’s a header file that contains functions for
basic input and output operations.
 by Writing include iostream or including that
header file then we have access to a whole
bunch of useful in for input and output
operations.
 Then we need the main function, it is where
the program begin.
 We begin the program by invoking the main
function
 int main() {

return 0;
 }
 At the end of our main function need to return
0 with a semicolon.
 if we reach return 0 that means there were no
problems in this program,
 however if one is returned that means there
was a problem.
 so please return 0 at the end of your main
function.
 std::cout << "I like cake!“;

 std::cout is used to print out the out put, then follow


two left angle brackets then within quotation you
can write anything you want display.

 And the end of the statement end with semi-colon,


this tells the compiler that the statement is done go
to the next one.

 Std means standard and cout means character out,


together it means standard character out.

.
 #include <iostream>

int main() {

 //This is comment
 /*
 This is
 Multi-line
 Comment.
 */

//std::cout << "I like cake!" << std::endl;
 std::cout << "I like cake!" << '\n';
 std::cout << "it's really sweet1!" << '\n';

return 0;
 }
“The way to get started is to quit talking
and begin doing.”
– Walt Disney

You might also like