Sie sind auf Seite 1von 44

OFFICIAL PRACTICAL REPORT OF COMPUTER

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

DEPARTMENT OF ENGINEERING PHYSICS


FACULTY OF INDUSTRIAL TECHNOLOGY
INSTITUT TEKNOLOGI SEPULUH NOPEMBER
SURABAYA
2019

2
iii

OFFICIAL PRACTICAL REPORT OF COMPUTER


PROGRAMMING
P1 – BASIC PROGRAMMING OF C++

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

DEPARTMENT OF ENGINEERING PHYSICS


FACULTY OF INDUSTRIAL TECHNOLOGY
INSTITUT TEKNOLOGI SEPULUH NOPEMBER
SURABAYA
2019
(This page is intentionally left blank)
ABSTRACT

In this practice we use a software to making a program, such


as Microsoft Visual Studio 2017. The programming language
used is C++. From this practice we can make a Body Mass
Index Program
(This page is intentionally left blank
ACKNOWLEDGEMENT

All praise for Allah SWT has given us convenience so we can


finish this paper on time. Without His help, of course we will
not be able to finish this paper properly. Prayers and greetings
may best be poured out to our beloved. The authors thank
Allah SWT for the abundance of His healthy favors, both in
the form of physical and mindfulness, so that the writers are
able to complete the making of this official report. The
authors certainly realize that this paper is far from perfect and
there are still many errors and shortcomings in it. For this
reason, the author expect criticism and suggestions from
readers for this paper, so that this paper can become a better
paper. Thus, and if there are many mistakes in this paper the
author apologizes profusely. The authors also thank all parties,
especially to our Laboratory Assistant, Mas Imam, who has
guided us in writing this official report. In all hopes that this
paper can be useful. Thank You.

Surabaya, 3 Mei 2019

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

Figure 3. 1 Display IDE Visual Studio


2017……………………...9
Figure 3. 2 Create new project.........................................................10
Figure 3. 3 New Project.......................................................................

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

2.1. The Five Basic Data Types


There are five atomic data types in the C subset:
character, integer, floating point, double floating point, and
valueless (char, fload, double, and void, respectively). All data
types in C are based upon one of these types. The size and range
of these data types in C may vary between processor types and
compilers.

Table 2.1 Data Types


Type Typical Size in Minimal Range
Bits
char 8 -127 to 127
unsigned char 8 0 to 255
signed char 8 -127 to 127
Int 16 or 32 -32,767 to 32,767
unsigned int 16 or 32 0 to 65,535
signed int 16 or 32 Same as int
short int 16 -32,367 to 32,767
unsigned short int 16 0 to 65,535
signed short int 16 same as short int
long int 32 -2,147,483,647 to
2,147,483,647
signed long int 32 Same as long int
unsigned long int 32 0 to 4,294,967,295
float 32 Six digits of
precision
double 64 Ten digits of
precision
long double 80 Ten digits of
precision

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.

2.5 Decision control Structure


Decision control structure is a command / statement that
we use to regulate the course of a program. control structure is
used to set the program so that it can run under certain

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.6 Repetition Control Structure


Repetition Control Structure is used to repeat blocks or
parts of the program code. there are 3 forms of repetition control
structure functions for repetition, namely the for, while and do
while functions. the for function is used to repeat a command
with a known number of repetitions. the while function is used to
change one command to a certain condition. the do while
repetition function will run if the condition checked in while is
still true and the initialization will be terminated if the condition
is false.

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

Figure 3. 1 Display IDE Visual Studio 2017


Pada Solution Explorer, klik kanan pada <Project Name> lalu
Add->New Item

5. Pada form yang muncul, pilih UI->Windows Form lalu klik


tombol Add

6. MyForm.h akan tampil seperi pada gambar

Laboratorium Komputasi dan Sistem Fisik Cyber


10
7. Selanjutnya untuk Memanggil MyForm maka diperlukan
perintah untuk memanggilnya. Klik MyForm.cpp pada Source Files

Laboratorium Komputasi dan Sistem Fisik Cyber


11
Perintahuntuk PemanggilanForm
#include "MyForm.h"
using namespace Praktikum_P2;
using namespace System::Windows::Forms;
using namespace System::Windows;
int main()
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault
(false);
Praktikum_P2::MyForm form;
Application::Run(%form);
}
8. Setelah itu pada menu bar pilih PROJECT->

Laboratorium Komputasi dan Sistem Fisik Cyber


12
<Project_Name> Properties

9. Pada Configuration Properties, Pilih Linker->System. Kemudian pada


Subsystem pilih Windows(/SUBSYSTEM
WINDOWS). Dilanjutkan dengan mengisi main pada
Linker->Entry Point

Laboratorium Komputasi dan Sistem Fisik Cyber


13
10. Berikut tampilan sederhan form kosong dari pembuatan project di
visual C++. Dilanjutkan dengan desain atau pengisisan komponen
lainnya

Laboratorium Komputasi dan Sistem Fisik Cyber


14
b. Make the
project
using code and c++ language

Laboratorium Komputasi dan Sistem Fisik Cyber

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);

Laboratorium Komputasi dan Sistem Fisik Cyber

16
hasil =
Convert::ToDoubl
e(NilaiA /
NilaiB);
textBox3->Text = Convert::ToString(hasil);

4.1.1.1 Result Of The Program

Laboratorium Komputasi dan Sistem Fisik Cyber

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
“.

Laboratorium Komputasi dan Sistem Fisik Cyber

19
(This page is intentionally left blank)

Laboratorium Komputasi dan Sistem Fisik Cyber

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.

Laboratorium Komputasi dan Sistem Fisik Cyber

21
(This page is intentionally left blank)

Laboratorium Komputasi dan Sistem Fisik Cyber

22
REFERENCES

Laboratorium Komputasi dan Sistem Fisik Cyber

23
(This page is intentionally left blank)

Laboratorium Komputasi dan Sistem Fisik Cyber

24
APPENDIX I

Laboratorium Komputasi dan Sistem Fisik Cyber

25
Laboratorium Komputasi dan Sistem Fisik Cyber

26

Das könnte Ihnen auch gefallen