Beruflich Dokumente
Kultur Dokumente
PROGRAMMING
P1 – BASIC PROGRAMMING OF C++
1
ARRANGED BY :
GROUP 16
Mahenda Radityo 023 118 4000 0048
Cynthia Pramesti R.R. 023 118 4000 0072
Olivia Natasa Simarmata 023 118 4000 0106
M. Fikri Mumtaz 023 118 4000 0115
M. Tabayyun Yudhistira 023 118 4000 0130
Hasna Brillianza 023 118 4000 0132
ASSISTANT :
M. Imam Asrawi 023 117 4000 0067
2
iii
ARRANGED BY :
GROUP 16
Mahenda Radityo 023 118 400 00003
Cynthia Pramesti R.R. 023 118 400 00021
Olivia Natasa Simarmata 023 118 400 00066
M. Fikri Mumtaz 023 118 400 00109
M. Tabayyun Yudhistira 023 118 400 00124
Hasna Brillianza 023 118 400 00129
ASSISTANT :
M. Imam Asrawi 023 117 4000 0067
Author
(This page is intentionally left blank)
TABLE OF CONTENT
TITLE PAGE.........................................................................iii
ABSTRACT...........................................................................v
ACKNOWLEDGEMENT....................................................vii
TABLE OF CONTENT.........................................................xi
LIST OF FIGURE................................................................xii
LIST OF TABLE.................................................................xiv
CHAPTER I INTRODUCTION.............................................1
1.1. Background.............................................................1
1.2. Problems.................................................................2
1.3. Aims........................................................................2
CHAPTER II BACKGROUND THEORY.............................4
2.1. The Five Basic Data Types......................................4
2.2. Data Types..............................................................4
2.3. Operator..................................................................5
2.4. Array.......................................................................5
2.5. Decision Control Structure......................................5
2.6. Repetition Control Structure...................................6
2.7. Function..................................................................6
2.8. Header.....................................................................6
2.9. Pointer.....................................................................7
2.10. Struct.......................................................................7
CHAPTER III METHODS.....................................................9
3.1. Tools.......................................................................9
3.2. Procedure................................................................9
CHAPTER IV RESULT AND DISCUSSION......................11
4.1. Result(s)................................................................11
4.1.1. Program Coding................................................11
4.1.2. Result Of the Program.......................................15
4.2. Discussion.............................................................17
4.2.1. Mahenda Radityo..............................................17
4.2.2. Cynthia Pramesti R.R........................................17
4.2.3. Olivia Natasa Simarmata...................................17
4.2.4. M. Fikri Mumtaz...............................................17
4.2.5. M. Tabayyun Yudhistira....................................18
4.2.5. Hasna Brillianza................................................18
CHAPTER V CONCLUSION..............................................20
5.1. Conclusion............................................................20
5.2. Suggestion.............................................................20
REFERENCES.....................................................................22
APPENDIX I........................................................................24
(This page is intentionally left blank)
LIST OF FIGURE
10
Figure 4. 1 Awal...............................................................................15
Figure 4. 2 Tengah...........................................................................16
Figure 4. 3 Akhir..............................................................................16
(This page is intentionally left blank)
LIST OF TABLE
Table 2. 1 Data Types.....................................................4
(This page is intentionally left blank)
xv
CHAPTER I
INTRODUCTION
1.1. Background
In this era, all machine are connected to the internet or
usually called Internet of Things. Internet of Thing also occurs
where certain objects have the ability to transfer data over the
network without interaction from human to human or from
humans to computer devices.
Programming languages are divided into 4 groups,
namely: high-level languages (Visual Basic, Pascal, Java, and
PHP), intermediate level languages (Language C), low-level
languages (Assembly). C++ Language, is a development language
of C. C and C++ languages has almost the same writing syntax. If
there is one language that defines modern programming, it is C+
+. Its syntax, style, and philosophy have set the standard by which
all other languages are judged. Furthermore, C++ is the universal
language of programming. When an algorithm or technique is
described, it is usually done so using the C++ syntax. The long-
term success of C++ has also left a lasting impression on
computer language development. For example, both Java and C#
are descended from C++. Frankly, to be a professional
programmer implies proficiency in C++. It is the one language
that no programmer can afford to ignore. In the 21st century, the
world finally entered a new era called the Industrial Revolution
4.0.
There are many applications for creating C++
programming languages, namely Borland C++, Dev C++, Code
Blocks, Microsoft Visual C++ (Visual Studio), and Netbeans.
Microsoft Visual Studio is an application that can be used to
develop app. In Microsoft Visual Studio, there are many things
1
that can be learned and developed. Therefore, the practival work
are carried out to be able to learn and use C++ in Microsoft Visual
Studio.
1.2. Problems
Based on the background, the problems discussed can be
formulated as follows:
a. What Is Data Types ?
b. How to use Operators Properly ?
c. What is Array and how to use it ?
d. How many Decision Control Structure are exists and how
to use it ?
e. How many Loop Control Structure are exists and how to
use it ?
f. How to use Function ?
g. How to use Header ?
h. How to use Pointer ?
i. How to use Struct ?
1.3. Aims
In this practical work, there are several goals to be
achieved :
a. Understand the meaning of Data Types
b. Understand the use of Operators
c. Understand about Arrays
d. Understand about Decision Control Structure
e. Understand about Loop Control Structure
f. Understand the use of Function
g. Understand the use of Header
h. Understand the use of Pointer
i. Understand the use of Struct
2
(This page is intentionally left blank)
3
CHAPTER II
BACKGROUND THEORY
4
2.2 Data Types
The data type is the set you can find on all the data. One
form of application of data types in daily life is on integers. There
are 2 types of data type, primitive and non-primitive.
Primitive data types are data types that are defined by
default in a programming language or can also be referred to as
the basic data types that are most often used by most
programmers, for example integer, float, char, boolean and so
on.While the non primitive data type is a data type that is by
default not defined by a programming language and is defined by
the programmer itself. The most common example of this non
primitive data type is strings and arrays.
2.3 Operator
An operator is a special character that is used to produce
a value or a symbol or sign used to operate two or more values to
get results. And there are 2 types of operators, arithmetic
operators and logic operators. Arithmetic operators are used to
perform processing operations on data values. While the logic
operators are used to process values or expressions with boolean
data types. the results of logical operations are values with
boolean data types, namely true and false.
2.4 Array
Array is a structured data type in the form of a number of
similar data whose numbers are fixed and given a certain name.
Arrays are used to store the data entered each into computer
memory. array elements are of the same data type but can have
the same or different values. Arrays store data sequentially on
computer memory. When an array is declared, the computer will
allocate a number of places in the computer memory that are
always located close together.
5
conditions. There are 2 functions of decision control structure,
namely, if function and switch function. IF is used if we have a
condition where the condition is TRUE. whereas switches are
selection statements to manipulate the nets of program flow
based on conditional expressions, controlling the flow of
programs so that they can run flexibly on the state of the program
and the wishes of the user.
2.7 Function
Function is a group of named programs, so if it is needed
it can be called back. the function can manipulate data and can
return a value. The function consists of 2 types, namely user-
defined functions and built-in functions.
2.8 Header
The header file is a major declaration of a program with
the C ++ programming language, in this case the header file
functions to perform functions contained in the C ++
programming language. The functions that we use (cout, cin,
printf, getch, etc.) depend on the header file that we use. So these
are some examples of header file, #include<iostream>,
#include<stdio.h>, and #include<math.h>. The header file
#include<iostream> used to display the cin command that serves
for input function is used to store the data in a variable. cout is an
output function used to display data or writing. endl is used to
move the line. The header file #include<stdio.h> used to displays
the printf command for the output function, scanf is an input
6
function and gets input functions that can read spaces. The header
file <math.h> used to sqrt for root functions, pow for power
functions, sin (), cos () and tan () are each used to calculate the
values of sin, cos, tan. max is used to calculate the division and
the remaining shares. min is used to specify the smallest number
of two numbers.
2.9 Pointer
Pointer is a pointer variable containing a value that shows
the address of a particular memory location. so the pointer does
not contain data values, but contains a memory address. There are
two operators used in pointer data types, namely operator
deference (&) and reference operator (*). Deference operators are
usually called address of or address operators. By using operator
deference, a variable will produce a memory address. While,
reference operators are usually called value pointed by. by using
this operator, can directly access the value contained in a memory
address.
2.10 Struct
Struct or record is a data set that has a different data type.
Structs are very different from arrays which only have one data
type for their set. Struct is used if the data you want to group has
different data types.
7
(This page is intentionally left blank)
8
CHAPTER III
METHODS
3.1. Tools
In this peogramming experiment there are several tools
used,namely:
a. Laptop
b. Module
c. Visual studio 2017
3.2. Procedure
In this programming experiment there are several steps
to work that must be done:
a. Open Visual Studio 2017
15
CHAPTER IV
RESULT
AND DISCUSSION
4.1. Result(s)
4.1.1 Program Coding Calculator
private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e) {
float NilaiA, NilaiB;
double hasil;
NilaiA = float::Parse(textBox1->Text);
NilaiB = float::Parse(textBox2->Text);
hasil = Convert::ToDouble(NilaiA +
NilaiB);
textBox3->Text = Convert::ToString(hasil);
}
private: System::Void button2_Click(System::Object^
sender, System::EventArgs^ e) {
float NilaiA, NilaiB;
double hasil;
NilaiA = float::Parse(textBox1->Text);
NilaiB = float::Parse(textBox2->Text);
hasil = Convert::ToDouble(NilaiA - NilaiB);
textBox3->Text = Convert::ToString(hasil);
}
private: System::Void button3_Click(System::Object^
sender, System::EventArgs^ e) {
float NilaiA, NilaiB;
double hasil;
NilaiA = float::Parse(textBox1->Text);
NilaiB = float::Parse(textBox2->Text);
hasil = Convert::ToDouble(NilaiA * NilaiB);
textBox3->Text = Convert::ToString(hasil);
}
private: System::Void button4_Click(System::Object^
sender, System::EventArgs^ e) {
float NilaiA, NilaiB;
double hasil;
NilaiA = float::Parse(textBox1->Text);
NilaiB = float::Parse(textBox2->Text);
16
hasil =
Convert::ToDoubl
e(NilaiA /
NilaiB);
textBox3->Text = Convert::ToString(hasil);
17
Laboratorium Komputasi dan Sistem Fisik Cyber
18
4.1.1.2 Discussion
4.1.1.2.1. Muhammad Fikri Mumtaz
the calculator program uses labels as "Numbers 1", "Number 2",
"RESULTS", then uses textbox1 and textbox2 on each label "Number 1",
"Number 2" whose function is to enter numbers. on this program using
4 buttons namely "+", "-", "*", "/". on each button has a data type,
namely float NilaiA, NilaB, where float is a data type so we can enter
numbers that have a decimal part at the end of the number.
4.1.1.2.2. M. Tabayyun Yudhistira
Lalu var NilaiA, dan NilaiB adalah variabel yg didapatkan setelah kita
memasukkan angka pada textbox 1 dan textbox 2, jika dicontohkan
pada button “+” maka setelah itu dimasukkan angkanya diproses, di
mana hasilnya = NilaiA + NilaiB lalu akan keluar nilai angka dari
pemprosesan tersebut pada textboxt 3 yang dekat dengan label “ Hasil
“.
19
(This page is intentionally left blank)
20
CHAPTER V
CONCLUSION
5.1 Conclusion
Based on experiment that has been done, can be concluded:
a. There are several type of data in c++ that has it’s own
function, the use is depend on what type of data that the
program needed.
b. There are two types of operator, they are arithmetic
operator and logical operator.
c. Array is type of data that composed by some homogenous
data type.
d. Decision control structure in c++ is using if function and
switch function.
e. Looping control structure in c++ is using while loop, do…
while loop, and for loop.
f. A function is a group of statements that together perform a
task and can be called whenever it’a needed.
g. Header files contain definitions of Functions and Variables,
which is imported or used into any C++ program by using
the pre-processor #include statement
h. Pointer is a variable that stores the address of another
variable.
i. Struct is a collection of variables of different data types
under a single name.
5.2 Suggestion
Based on experiment that has been done, these are
suggestion for better experiment next time.
a. Don't use mac pc if experiment need visual studio c++,
because mac doesn't support c++.
b. The additional duty should be made easier.
21
(This page is intentionally left blank)
22
REFERENCES
23
(This page is intentionally left blank)
24
APPENDIX I
25
Laboratorium Komputasi dan Sistem Fisik Cyber
26