0% found this document useful (0 votes)
70 views31 pages

Pengenalan Algoritma dan Pemrograman C++

The document provides an introduction to algorithms and programming concepts. It defines an algorithm as a step-by-step process for solving a problem and notes they can be represented through pseudocode, flowcharts, or natural language. Flowcharts are described as using graphical symbols to represent an algorithm or program. Examples are given to demonstrate algorithms and their corresponding flowcharts for tasks like printing numbers, converting temperatures, and determining if a student passed an exam. The document then begins discussing programming concepts like variables, data types, and how variables are declared and used in C programming.

Uploaded by

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

Pengenalan Algoritma dan Pemrograman C++

The document provides an introduction to algorithms and programming concepts. It defines an algorithm as a step-by-step process for solving a problem and notes they can be represented through pseudocode, flowcharts, or natural language. Flowcharts are described as using graphical symbols to represent an algorithm or program. Examples are given to demonstrate algorithms and their corresponding flowcharts for tasks like printing numbers, converting temperatures, and determining if a student passed an exam. The document then begins discussing programming concepts like variables, data types, and how variables are declared and used in C programming.

Uploaded by

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

PERTEMUAN 1

Algoritma dan
Pemprograman
Wib b y A ld rya ni, [Link]., M .T., M .E ng
Content

DESKRIPSI SINGKAT: PENGENALAN KONSEP ALGORITMA CAPAIAN PEMBELAJARAN: MAMPU MENJELASKAN


DAN PEMPROGRAMAN KONSEP DASAR ALGORITMA DAN PEMPROGRAMAN,
SERTA
PENGENALAN BAHASA PEMPROGRAMAN
What is a Algorithm?

Writing a logical step-by-step method to solve the


problem is called the algorithm. In other words, an
algorithm is a procedure for solving problems. In
order to solve a mathematical or computer problem,
this is the first step in the process.

An algorithm includes calculations, reasoning, and


data processing. Algorithms can be presented by
natural languages, pseudocode, and flowcharts, etc.
Definition of Flowchart
Several standard symbols are applied in a flowchart:

A flowchart is the graphical or


pictorial representation of an
algorithm with the help of different
symbols, shapes, and arrows to
demonstrate a process or a program.
With algorithms, we can easily
understand a program. The main
purpose of using a flowchart is to
analyze different methods.
Difference between Algorithm and
Flowchart
Example 1: Print 1 to 20:
Algorithm: Flowchart
•Step 1: Initialize X as 0,
•Step 2: Increment X by 1,
•Step 3: Print X,
•Step 4: If X is less than 20 then go back to step 2.
Example 2: Convert Temperature from
Fahrenheit (℉) to Celsius (℃)
Algorithm: Flowchart
•Step 1: Read temperature in Fahrenheit,
•Step 2: Calculate temperature with formula C=5/9*(F-32),
•Step 3: Print C.
Example 3: Determine Whether A
Student Passed the Exam or Not:
Algorithm: Flowchart
•Step 1: Input grades of 4 courses M1, M2, M3 and M4,
•Step 2: Calculate the average grade with formula
"Grade=(M1+M2+M3+M4)/4"
•Step 3: If the average grade is less than 60, print "FAIL", else
print "PASS".
Thank you
PERTEMUAN 2

Algoritma dan
Pemprograman
Wib b y A ld rya ni, [Link]., M .T., M .E ng
Content

DESKRIPSI SINGKAT: MAHASISWA AKAN BELAJAR CARA CAPAIAN PEMBELAJARAN: MAHASISWA AKAN BELAJAR
MENGINSTAL SOFTWARE DEV MEMBUAT PROGRAM SEDERHANA DENGAN
C++ DAN MENGATUR SOFTWARE TERSEBUT SESUAI MENERAPKAN FUNGSI INPUT DAN OUTPUT
KEPERLUAN (I/O) MENGGUNAKAN BAHASA PEMROGRAMAN C++.
What is a Binary?
0 dan 1 dikenal dengan bit. Binary Digit atau disingkat
Bit. Binary merupakan system bilangan biner (Binary
Number system)
Bit yang digunakan adalah 8 bit biner.
8 bit biner dinamakan byte.
Pada system biner, perhitungan kombinasi dihitung dengan 2n ≤ m,
di mana n adalah jumlah bit,
m adalah kombinasi dapat diwakili, sehingga sedikit 8 bit, dapat
mewakili sampai 28 = 256 kombinasi.

Ketika Anda mengetik simbol kata "digital" yang digunakan 6 poin,


saat computer memproses kata digital terdiri 6 huruf yang diproses
menjadi 6 byte, yang kemudian
disimpan dalam memori computer (RAM) saat Anda mengetik, dan
kemudian disimpan pada hard disk jika disimpan.
Sistem Bilangan
Sistem yang paling umum digunakan adalah jumlah sistem desimal, biner, oktal dan
heksadesimal.

Sistem angka desimal adalah sistem digital yang paling banyak digunakan oleh manusia
untuk berbagai mudah digunakan setiap hari.

Sistem biner adalah sistem digital yang paling banyak digunakan di sistem digital sistem
digital ini secara langsung mewakili logika yang ada, sedangkan sistem nomor oktal dan
heksadesimal banyak digunakan dalam sistem digital untuk mempersingkat presentasi
dari sejumlah yang telah disajikan dalam sistem biner, jadi mudah dimengerti atau
disimpan
Desimal
Sistem bilangan desimal disusun oleh 10 angka atau lambang.
Dengan menggunakan lambang-lambang tersebut sebagai digit pada sebuah
bilangan, maka akan dapat mengekspresikan suatu kuantitas. Ke-10 lambang
tersebut adalah:

Sistem bilangan desimal disebut juga sistem bilangan


basis 10 atau radiks
10 karena mempunyai 10 digit.
Sistem bilangan ini bersifat alamiah karena pada
kenyataannya manusia mempunyai 10 jari. Kata digit itu
sendiri diturunkan dari kata bahasa Latin finger.
Ciri Bilangan Desimal
Ciri bilangan yang menggunakan sistem bilangan desimal
adalah adanya tambahan subskrip des atau 10 atau
tambahan D di akhir suatu bilangan.
Pada bilangan tersebut, digit 3 berarti 3
ratusan, 5 berarti 5 puluhan, dan 7
berarti 7 satuan. Sehingga, 3 mempunyai
Namun karena bilangan desimal sudah menjadi bilangan
arti paling besar di antara tiga digit
yang digunakan sehari-hari, subskrip tersebut biasanya
yang ada.
dihilangkan. Sistem bilangan decimal merupakan sebuah
sistem nilai posisi. Digit ini bertindak sebagai digit paling
berarti (Most Significant Digit, MSD).
Sedangkan 7 mempunyai arti paling kecil
di antara tiga digit yang ada dan disebut
digit paling tidak berarti (Least Significant
Digit, LSD).
Selengkapnya pelajari di Bahan Ajar teori
Latihan Sistem Bilangan
Variables
A variable is a name of the memory location. It is used to store
data. Its value can be changed, and it can be reused many
times.
It is a way to represent memory location through symbol so
that it can be easily identified.
Let's see the syntax to declare a variable:
The example of declaring the variable is
given below:

Here, a, b, c are variables.


The int, float, char are the data types.
Declaring Variable

We can also provide values while declaring the variables as


given below:
Rules Variables
•A variable can have alphabets, digits, and underscore.
•A variable name can start with the alphabet, and underscore
only. It can't start with a digit.
•No whitespace is allowed within the variable name.
•A variable name must not be any reserved word or keyword,
e.g. int, float, etc.
Types of Variables in C

There are many types of variables in c:


[Link] variable
[Link] variable
[Link] variable
[Link] variable
[Link] variable
Local Variable

A variable that is declared inside the function


or block is called a local variable.
It must be declared at the start of the block.
Global Variable
A variable that is declared outside the function or block is
called a global variable. Any function can change the value of
the global variable. It is available to all the functions.
It must be declared at the start of the block.
Static Variable
A variable that is declared with the static keyword is called
static variable.
It retains its value between multiple function calls.

If you call this function many times, the local variable will print
the same value for each function call, e.g, 11,11,11 and so on.
But the static variable will print the incremented value in each
function call, e.g. 11, 12, 13 and so on.
Automatic Variable
All variables in C that are declared inside the block, are
automatic variables by default. We can explicitly declare an
automatic variable using auto keyword.
External Variable
We can share a variable in multiple C source files by using an
external variable. To declare an external variable, you need to
use extern keyword.
Data Types in C
A data type specifies the type of data that a variable can store
such as integer, floating, character, etc.
Thank you

You might also like