Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

Introduction To Computer Programming

The document provides an introduction to computer programming with a focus on C++. It covers key concepts such as algorithms, computer languages (machine, assembly, and high-level languages), and methods for representing algorithms like pseudocode and flowcharts. Additionally, it discusses the features of C++, its usage, and a simple example of writing a C++ program using the Dev C++ IDE.

Uploaded by

twoflipflops8
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Introduction To Computer Programming

The document provides an introduction to computer programming with a focus on C++. It covers key concepts such as algorithms, computer languages (machine, assembly, and high-level languages), and methods for representing algorithms like pseudocode and flowcharts. Additionally, it discusses the features of C++, its usage, and a simple example of writing a C++ program using the Dev C++ IDE.

Uploaded by

twoflipflops8
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction To Computer

Programming
C++ programming
Key Words to be understood are;

 Algorithm
 Machine Language
 Assembler Language
 High-level Language
Algorithm

 “a finite sequence of unambiguous,


executable steps or instructions, which, if
followed would ultimately terminate and give
the solution of the problem”.
 algorithm is a stepwise description of an
action that leads the problem from its start
state to its goal state.
An algorithm must be very clear, definite, and
efficient for the problem it aims at solving.
Computer Languages

 All computer languages can be classified into the following three


basic categories:
 1. Machine language
 2. Assembly language
 3. High-level language
Machine Language
 In most machine languages, binary digits (bits 0 and 1)
represent everything, namely, instructions, data, and
variables. Binary numbers are composed entirely of
zeros and ones.
 Programs written in machine language can be executed
very fast by computers. This is because machine
instructions are directly understood by the computer
and no translation program is required.
 However, these programs consisting of a sequence of
zeros and ones are difficult to read, write, and interpret
by humans.
Assembly Language

 Assembly languages are a major improvement over


machine languages. In an assembly language, a
short name, rather than a big binary number,
defines each instruction and identifies each variable.
 Programs written in assembly language require a
special program called the assembler that translates
assembly language instructions into machine
language instructions. Nowadays, programs are
written in assembly language only when the speed
of execution is of high priority.
High-level language
A high-level language, instead of being machine-dependent,
is oriented towards the problem to be solved. These
languages enable the programmer to write instructions using
English words and familiar mathematical symbols. Every
instruction that the programmer writes in a high-level
language is translated into a set of machine language
instructions. This is known as one-to-many translation.
Today, there are over 200 high-level languages. Some of the
most common ones are C, C++, Java, Pascal, FORTRAN, and
COBOL. A system program that translates a high-level
language such as C++ to a machine language is called a
compiler. It is thus a peculiar sort of program whose input is
one program and output is another program.
An example of a compiler used for C++ is Dev C++
Representation of Algorithms

Several methods exist for


representing algorithms. Among
these are:
Pseudocode
Flowchart
Pseudocode
 Pseudocode is an informal way of programming description that does
not require any strict programming language syntax or underlying
technology considerations. It is used for creating an outline or a rough
draft of a program
 For example a Pseudocode to withdraw money from the ATM machine.
Program starts
1. Insert your card
2. Input/ enter your pin
3. Select withdraw
4. Enter the amount you want to withdraw
5. If the amount entered is more than the balance show a message
transaction not successful
6. otherwise if amount entered is less than balance show a message
transaction was successful.
7. Program ends
Flow chart

A flowchart is a type of diagram that


represents an algorithm, workflow
or process. The flowchart shows the
steps as boxes of various kinds, and
their order by connecting the boxes
with arrows. This diagrammatic
representation illustrates a solution
model to a given problem
Symbols used in flow charts
Programming in C++

 What is C++?
 C++ is a cross-platform language that can be used to create high-
performance applications.
 C++ was developed by Bjarne Stroustrup, as an extension to the
C language.
 C++ gives programmers a high level of control over system resources
and memory.
 The language was updated 3 major times in 2011, 2014, and 2017 to
C++11, C++14, and C++17.
Why Use C++

 C++ is one of the world's most popular programming


languages.
 C++ can be found in today's operating systems,
Graphical User Interfaces, and embedded systems.
 C++ is an object-oriented programming language which
gives a clear structure to programs and allows code to be
reused, lowering development costs.
 C++ is portable and can be used to develop applications
that can be adapted to multiple platforms.
 C++ is fun and easy to learn!
C++ Getting Started

 To start using C++, you need two things:


 A text editor, like Notepad, to write C++ code
 A compiler, like GCC, to translate the C++ code into a language that
the computer will understand
 There are many text editors and compilers to choose from. In this
class , we will use an IDE Dev C++
Compiler Dev C++
C++ Quick start

Let's create our first C++ file.


Open Dev C++ and go to File > New >
Empty File.
Write the following C++ code and save
the file as myfirstprogram.cpp (File >
Save File as):
myfirstprogram.cpp

#include <iostream>
using namespace std;

int main() {
cout << "Hello World!";
return 0;
}
In Dev C++ it looks like this
When click on compile and run it
looks like this

Hello World!
Process returned 0 (0x0) execution time : 0.011 s
Press any key to continue

You might also like