Rabu, 26 Mei 2010

TekomC...!!!!!

Judul : Rangkuman sesi 1 - 9
Nama : lukman kamaludin
kelas : 1 ti 1
NRP : 6309074
Prodi : MI
Jurusan : TI
Dosen : dadan nurdin bagenda
Kampus : PKN LPKIA

class

Classes (I)
A class is an expanded concept of a data structure: instead of holding only data, it can hold
both data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type, and an
object would be the variable.
Classes are generally declared using the keyword class, with the following format:
class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
} object_names;
Where class_name is a valid identifier for the class, object_names is an optional list of
names for objects of this class. The body of the declaration can contain members, that can be
either data or function declarations, and optionally access specifiers.
All is very similar to the declaration on data structures, except that we can now include also
functions and members, but also this new thing called access specifier. An access specifier is
one of the following three keywords: private, public or protected. These specifiers
modify the access rights that the members following them acquire:
• private members of a class are accessible only from within other members of the
same class or from their friends.
• protected members are accessible from members of their same class and from their
friends, but also from members of their derived classes.
• Finally, public members are accessible from anywhere where the object is visible.
By default, all members of a class declared with the class keyword have private access for all
its members. Therefore, any member that is declared before one other class specifier
automatically has private access. For example:
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area (void);
} rect;
Declares a class (i.e., a type) called CRectangle and an object (i.e., a variable) of this class
called rect. This class contains four members: two data members of type int (member x
and member y) with private access (because private is the default access level) and two
member functions with public access: set_values() and area(), of which for now we have
only included their declaration, not their definition.
Notice the difference between the class name and the object name: In the previous example,
CRectangle was the class name (i.e., the type), whereas rect was an object of type
CRectangle. It is the same relationship int and a have in the following declaration:
int a;
where int is the type name (the class) and a is the variable name (the object).
After the previous declarations of CRectangle and rect, we can refer within the body of the
program to any of the public members of the object rect as if they were normal functions or
normal variables, just by putting the object's name followed by a dot (.) and then the name
of the member. All very similar to what we did with plain data structures before. For example:
rect.set_values (3,4);
myarea = rect.area();
The only members of rect that we cannot access from the body of our program outside the
class are x and y, since they have private access and they can only be referred from within
other members of that same class.
Here is the complete example of class CRectangle:
// classes example
#include
using namespace std;
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area () {return (x*y);}
};
void CRectangle::set_values (int a,
int b) {
x = a;
y = b;
}
int main () {
CRectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
area: 12
The most important new thing in this code is the operator of scope (::, two colons) included
in the definition of set_values(). It is used to define a member of a class from outside the
class declaration itself.
You may notice that the definition of the member function area() has been included directly
within the definition of the CRectangle class given its extreme simplicity, whereas
set_values() has only its prototype declared within the class, but its definition is outside it.
In this outside declaration, we must use the operator of scope (::) to specify that we are
defining a function that is a member of the class CRectangle and not a regular global
function.
The scope operator (::) specifies the class to which the member being declared belongs,
granting exactly the same scope properties as if this function definition was directly included
within the class definition. For example, in the function set_values() of the previous code,
we have been able to use the variables x and y, which are private members of class
CRectangle, which means they are only accessible from other members of their class.
The only difference between defining a class member function completely within its class and
to include only the prototype and later its definition, is that in the first case the function will
automatically be considered an inline member function by the compiler, while in the second it
will be a normal (not-inline) class member function, which in fact supposes no difference in
behavior.
Members x and y have private access (remember that if nothing else is said, all members of a
class defined with keyword class have private access). By declaring them private we deny
access to them from anywhere outside the class. This makes sense, since we have already
defined a member function to set values for those members within the object: the member
function set_values(). Therefore, the rest of the program does not need to have direct
access to them. Perhaps in a so simple example as this, it is difficult to see an utility in
protecting those two variables, but in greater projects it may be very important that values
cannot be modified in an unexpected way (unexpected from the point of view of the object).
One of the greater advantages of a class is that, as any other type, we can declare several
objects of it. For example, following with the previous example of class CRectangle, we could
have declared the object rectb in addition to the object rect:
// example: one class, two objects
#include
using namespace std;
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area () {return (x*y);}
};
void CRectangle::set_values (int a,
int b) {
x = a;
y = b;
}
int main () {
CRectangle rect, rectb;
rect.set_values (3,4);
rectb.set_values (5,6);
cout << "rect area: " <<
rect.area() << endl;
cout << "rectb area: " <<
rectb.area() << endl;
return 0;
}
rect area: 12
rectb area: 30
In this concrete case, the class (type of the objects) to which we are talking about is
CRectangle, of which there are two instances or objects: rect and rectb. Each one of
them has its own member variables and member functions.
Notice that the call to rect.area() does not give the same result as the call to
rectb.area(). This is because each object of class CRectangle has its own variables x and
y, as they, in some way, have also their own function members set_value() and area()
that each uses its object's own variables to operate.
That is the basic concept of object-oriented programming: Data and functions are both
members of the object. We no longer use sets of global variables that we pass from one
function to another as parameters, but instead we handle objects that have their own data
and functions embedded as members. Notice that we have not had to give any parameters in
any of the calls to rect.area or rectb.area. Those member functions directly used the
data members of their respective objects rect and rectb.
Constructors and destructors
Objects generally need to initialize variables or assign dynamic memory during their process of
creation to become operative and to avoid returning unexpected values during their execution.
For example, what would happen if in the previous example we called the member function
area() before having called function set_values()? Probably we would have gotten an
undetermined result since the members x and y would have never been assigned a value.
In order to avoid that, a class can include a special function called constructor, which is
automatically called whenever a new object of this class is created. This constructor function
must have the same name as the class, and cannot have any return type; not even void.
We are going to implement CRectangle including a constructor:
// example: class constructor
#include
using namespace std;
class CRectangle {
int width, height;
public:
CRectangle (int,int);
int area () {return
(width*height);}
};
CRectangle::CRectangle (int a, int
b) {
width = a;
height = b;
}
int main () {
CRectangle rect (3,4);
CRectangle rectb (5,6);
cout << "rect area: " <<
rect.area() << endl;
cout << "rectb area: " <<
rect area: 12
rectb area: 30
rectb.area() << endl;
return 0;
}
As you can see, the result of this example is identical to the previous one. But now we have
removed the member function set_values(), and have included instead a constructor that
performs a similar action: it initializes the values of x and y with the parameters that are
passed to it.
Notice how these arguments are passed to the constructor at the moment at which the objects
of this class are created:
CRectangle rect (3,4);
CRectangle rectb (5,6);
Constructors cannot be called explicitly as if they were regular member functions. They are
only executed when a new object of that class is created.
You can also see how neither the constructor prototype declaration (within the class) nor the
latter constructor definition include a return value; not even void.
The destructor fulfills the opposite functionality. It is automatically called when an object is
destroyed, either because its scope of existence has finished (for example, if it was defined as
a local object within a function and the function ends) or because it is an object dynamically
assigned and it is released using the operator delete.
The destructor must have the same name as the class, but preceded with a tilde sign (~) and
it must also return no value.
The use of destructors is especially suitable when an object assigns dynamic memory during
its lifetime and at the moment of being destroyed we want to release the memory that the
object was allocated.
// example on constructors and
destructors
#include
using namespace std;
class CRectangle {
int *width, *height;
public:
CRectangle (int,int);
~CRectangle ();
int area () {return (*width *
*height);}
};
CRectangle::CRectangle (int a, int
b) {
width = new int;
height = new int;
*width = a;
*height = b;
}
rect area: 12
rectb area: 30
CRectangle::~CRectangle () {
delete width;
delete height;
}
int main () {
CRectangle rect (3,4), rectb
(5,6);
cout << "rect area: " <<
rect.area() << endl;
cout << "rectb area: " <<
rectb.area() << endl;
return 0;
}

struct

Structs
Overview
(http://www.fredosaurus.com/notes-cpp/index.html)
In addition to the simple data types (int, char, double, ...) there are composite data types
which combine more than one data element. Arrays store elements of the same type,
which are accessed by subscript, eg, a[i]. Structs (also called records, or classes) group
elements which don't need to all be the same type, and are accessed by field (member)
name, eg, r.name.
Struct Declaration defines a new Type
The most common struct declaration in C++ is to define a new type. This example
represents information about products.
struct Product {
char mfg_id[4]; // 4 char code for the manufacturer.
char prod_id[8]; // 8-char code for the product
int price; // price of the product in dollars.
int qty_on_hand; // quantity on hand in inventory
};
This defines a new type, Product. The order of the fields is generally not important. Don't
forget the semicolon after the right brace. The convention is to capitalize the first letter in
any new type name.
Declaring struct variables
The new struct type can now be used to declare variables. For example,
Product widget;
Accessing the fields of a struct
Access the fields of a struct by using the "." operator followed by the name of the field.
widget.price = 200;
widget.qty_on_hand = 17;
strcpy(widget.mfg_id, "IBM");
strcpy(widget.prod_id, "Thingee");
Like database records
Structs are like database records - a row in a table, where the field names are like the
column names.
Problem - Points
Suppose we have the following problem. We want to read a set of (x, y) coordinates and
a name, then sort them in order increasing distance from the origin (0, 0). This is the kind
of data you might have if we digitized a map with the origin at some central point (eg,
London) and the coordinates of other cities.
Global Declaration
Types are usually used in more than one function, and are therefore global or defined in
an include file.
// Define a struct to hold each point.
struct Point {
float x; // x coordinate
float y; // y coordinate
char name[20]; // name of the point
};
Local Declarations
Point pts[1000]; // array to hold up to 1000 points.
int n = 0; // number of points in the array.
Reading the input
To read structs, you need to read each of the fields.
while (cin >> pts[n].name >> pts[n].x >> pts[n].y) {
n++;
}
Utility function to compute distance to origin
float dist(Point p) {
// Compute the distance from the origin
return sqrt(p.x*p.x + p.y*p.y);
}
Sorting an array of Points
Here's a simple bubble sort function that stops when there are no more exchanges. It sorts
Points by their distance from the origin by calling on the function defined above.
void bubbleSort(Point pt[], int size) {
bool doMore = true;
while (doMore) {
doMore = false; // Assume no more passes unless exchange made.
for (int i=0; iif (dist(pt[i]) > dist(pt[i+1])) {
// Exchange elements
Point temp = pt[i]; pt[i] = pt[i+1]; pt[i+1] = temp;
doMore = true; // Exchange requires another pass.
}
}
}
}
Problem - Product info
Let's use the Product struct, read into an array of Products, and sort by increasing price.
Global Declaration
Typically types are used in more than one function, and are therefore global or defined in
an include file.
struct Product {
char mfg_id[4]; // 4 char code for the manufacturer.
char prod_id[8]; // 8-char code for the product
int price; // price of the product in dollars.
int qty_on_hand; // quantity on hand in inventory
};
Local Declarations
Product prods[1000]; // array to hold up to 1000 products
int n = 0; // number of products in the array.
Reading the input
while (cin >> prods[n].mfg_id >> prods[n].prod_id
>> prods[n].price >> prods[n].qty_on_hand) {
n++;
}
Sorting the array of products
Here's a simple bubble sort function that stops when there are no more exchanges. This is
a fairly inefficient sort, and it's used here just as an example. Notice we can't compare the
entire struct, only individual fields.
void bubbleSort2(Product pd[], int size) {
bool doMore;
do {
doMore = false; // assume this is last pass over array
for (int i=0; iif (pd[i].price > pd[i+1].price) {
// exchange elements
Product temp = pd[i]; pd[i] = pd[i+1]; pd[i+1] = temp;
doMore = true; // after exchange, must look again
}
}
} while (doMore);
}
Struct Operations
Assume the following declaration
//--- Define a new struct type
struct Point {
int x;
int y;
};
//--- Declare some variables of type Point.
Point p1;
Point p2;
Point* paddr; // declare pointer to a Point struct
Member (field) selection - dot operator
The "." (dot) operator is used to select a member of a struct. This operator can be applied
to any expression that yields a struct (function call, subscription, etc).
int h = p1.x;
p2.y = p1.y;
Member (field) selection - arrow operator
When using a pointer to a struct, the "->" (arrow) operator is typically used as a more
readable way to both dereference the pointer and select a member. See -> operator.
// The following are equivalent.
int h = paddr->x // using arrow notation.
int h = (*paddr).x; // using deref plus dot.
Assignment
A struct variable can be assigned to/from.
p1 = p2;
Parameter
A struct can be passed to a function either as a value or a reference parameter. Large
structs are sometimes passed as reference parameters to avoid the cost of the copy, even
tho the value is not going to be changed.
Returned by function
A struct may be returned by a function.
Comparison - NO
The comparison operators do not work on structs. To compare structs, compare
individual fields.
if (p1.x==p2.x && p1.y==p2.y) . . .
It is not possible to write p1==p2.
There are good reasons to forbid comparison.
• What would a greater than comparison even mean on a Point for example.
• A bit-by-bit equal comparison is not feasible in general because there may be
padding or unfilled elements (eg in a C-string).
A subelement of array or another struct
A struct value can be used inside of another struct or as an element type in an array.
Arithmetic operators - NO
By default none of the arithmetic operators work on structs.
I/O - NO
The I/O operators >> and << do not work for structs; you must read/write the fields
individually.
Solutions
You may redefine operators so that they do work with your structs. When providing
functions and overloaded operators for your struct, use the class keyword instead -- it's
what programmers expect.

Sorting

D:\My Documents\algor\algor2\Sorting.doc 1
SORTING
1. BUBBLE SORT
Algoritma paling sederhana.
Langkah-langkah :
1. dua elemen pertama dibandingkan, dan pindahkan jika elemen2 < langkah="0" i =" 0"> data[i+1] then
Tamp = data[i];
data[i] = data[i+1];
data[i+1] = tamp;
End if
Endfor
Endfor
2. SELECTION SORT
Algoritma yang sederhana.
Langkah-langkah :
1. cari elemen yang paling kecil dari n elemen
2. tempatkan elemen ini pada posisi awal array
3. cari elemen yang paling kecil dari n-1 elemen
4. tempatkan elemen ini pada posisi kedua array
5. ulang sampai elemen tinggal satu
8
5
9
3
1
7
5
8
9
3
1
7
5
8
9
3
1
7
5
8
3
9
1
7
5
8
3
1
9
7
5
8
3
1
7
9
D:\My Documents\algor\algor2\Sorting.doc 2
Data asli Langkah 1 Langkah 2 Langkah 3 Langkah 4 Langkah 5
Algoritma
For langkah=0 to n-1 do
Min = data[langkah];
Posisi = 1;
For i = langkah+1 to n do
If data[i]< j =" j" ketemu =" true;" 2="1" jump="7/2,">=1)
{
ahir=7-jump;
urut=0; //flag
while(!urut)
{
urut=1; //flag for end looping
for (i=0;i=data[i+jump])
{
tamp=data[i];
data[i]=data[i+jump];
data[i+jump]=tamp;
urut=0; //reset flag
}
}
}
jump=jump/2;
}

Searching

D:\My Documents\algor\algor2\Search.doc Created by Yokivox
Search
1. Linear search
Syarat
Tabel : Sort / bebas
Data masukan banyak : sort / bebas
Tabel Data
A D
C B
D
B
E
Ciri : Selalu kembali keasal pencarian untuk data berikutnya.
2. Sequential search
Syarat
Tabel : Sort
Data masukan banyak : Sort
Tabel Data
A B
B D
C
D
E
Ciri : pencarian data kedua mulai dari data pertama yang telah ditemukan.
3. Binary search
Syarat
Tabel : Sort
Data masukan banyak : Bebas
Tabel Data
A D
B B
C
D
E
F
G
Misal:
Batas bawah = 0
Batas atas = 7, jika ganjil + 1 = 8
Indeks = (BB + BA)/2=4
Lanjut……..
Batas bawah = 4
Batas atas = tetap
Indeks = (BB + BA)/2=6……terus
bagi sampai ketemu
Ciri : pencarian data membagi tabel
menjadi dua, kemudian membagi lagi
hasil baginya terus sampai ketemu.
Potongan Algor binary
Array tabel[8], Input(data)
Int kiri=1, kanan=n, Cari=0;
While (cari <> 0 and kiri<=kanan)
Lokasi=(kiri+kanan)/2;
IF tabel[lokasi]=cari then
Cari=1;
ELSE
If tabel[lokasi] < data then
D:\My Documents\algor\algor2\Search.doc Created by Yokivox
Kiri = lokasi + 1;
Else
Kanan = lokasi -1;
Endif
Endif
IF Cari=1 then
Idx=lokasi;
Else
Output(tidak ditemukan);
Endif
#include
#include
int BinarySearch(int [], int, int);
int main()
{
clrscr();
const int NUMEL = 10;
int nums[NUMEL] = {5,10,22,32,45,67,73,98,99,101};
int item, location;
cout << "Enter the item you are searching for: ";
cin >> item;
location = BinarySearch(nums, NUMEL, item);
if (location > -1)
cout << "The item was found at index location "<< location <<
endl;
else
cout << "The item was not found in the list\n";
getch();
return 0;
}
// this function returns the location of key in the list
// a -1 is returned if the value is not found
int BinarySearch(int list[], int size, int key)
{
int left, right, midpt;
left = 0;
right = size - 1;
while (left <= right)
{
midpt = (int) ((left + right) / 2);
if (key == list[midpt])
{
return midpt; //data is found
}
D:\My Documents\algor\algor2\Search.doc Created by Yokivox
else if (key > list[midpt])
left = midpt + 1;
else
right = midpt - 1;
}
return -1; //return indicate that data is’t found
}

Pointer

Content

· Introduction

· Pengertian Pointer

· Deklarasi Pointer

· Operasi pada Pointer

· Pointer pada Array

· Pointer pada Struct

MODUL PRAKTIKUM STRUKTUR DATA 2008

POINTER C/C++

Be carefull with “THIS”!!


Introduction

Setiap kali kita mendeklarasikan variabel, C/C++ akan menyediakan alokasi memori untuk masing-masing variabel. Ukuran memori yang dialokasikan berbeda-beda tergantung dari tipe data variabelnya. Misalnya untuk integer 2 bytes, untuk float 4 bytes, dst. Jadi, setiap variabel yang kita deklarasikan mempunyai 2 atribut yaitu address dan value.

Pengertian Pointer

Pada pertemuan kali ini, kita akan membahas powerful feature dari bahasa pemograman C/C++, yaitu pointer. Pointer (variabel penunjuk) adalah suatu variabel yang berisi alamat memori dari suatu variabel lain. Pointer merupakan variabel level rendah yang dapat digunakan untuk menunjuk nilai integer, character, float, double, atau single, dan bahkan tipe-tipe data lain yang didukung oleh bahasa C.

Variabel biasa, sifatnya statis dan sudah pasti, sedangkan pada pointer sifatnya dinamis dan dapat lebih fleksibel. Variabel pointer yang tidak menunjuk pada nilai apapun berarti memiliki nilai NULL, dan disebut sebagai dangling pointer karena nilainya tidak diinisialisasi dan tidak dapat diprediksi.

Deklarasi Pointer

Seperti halnya variabel yang lain, variabel pointer juga harus dideklarasikan terlebih dahulu sebelum digunakan.

Bentuk Umum : tipe_data *nama_pointer;

Contoh : int *nilai;

char *huruf;

Pendeklarasian variabel pointer menggunakan tanda * sebelum nama variabelnya, sedangkan untuk menampilkan nilai yang ditunjuk oleh suatu variabel pointer, juga digunakan operator * (tanda asterisk). Jika diinginkan untuk menampilkan alamat tempat penyimpanan nilai yang ditunjuk oleh suatu variabel pointer, digunakan operator & (tanda ampersand).

Operasi pada Pointer

· Operasi Penugasan

Suatu variable pointer seperti halnya variable yang lain, juga bisa mengalami operasi

penugasan. Nilai dari suatu variable pointer dapat disalin ke variable pointer yang lain

Operator (&) dalam kaitannya dengan pointer adalah operator yang mengembalikan alamat memori dari operandnya. Contohnya :

int y = 5; /*deklarasi variabel y*/

int *yPtr; /*deklarasi variabel pointer yPtr*/

yPtr = &y; /*mengisi variabel pointer yPtr dengan alamat dari variabel y*/

Maka representasi dari operasi penugasan di atas adalah

Representasi yang lain, misalnya asumsikan bahwa variabel y berada pada alokasi memori 600000 dan variabel pointer yPtr berada pada alokasi memori 500000.

Contoh program (untuk dicoba)

Pertanyaan :

1. Perintah apa yang digunakan untuk menampilkan alamat dari variabel i, namun tanpa melalui pengaksesan variabel pointer ia?

Pertanyaan :

2. t = *p;

*p = *q;

*q = t;

Fungsi di atas ini (dengan pointer) untuk apakah itu?

Untuk membantu, coba tambahkan perintah di bawah ini pada program di atas:

printf("nilai yang ditunjuk p sekarang = %d di alamat %p\n",*p,p);

printf("nilai yang ditunjuk q sekarang = %d di alamat %p\n",*q,q);


· Operasi Aritmatika

Suatu variabel pointer hanya dapat dilakukan operasi aritmatika dengan nilai integer

saja. Operasi yang biasa dilakukan adalah operasi penambahan dan pengurangan.

Operasi penambahan dengan suatu nilai menunjukkan lokasi data berikutnya (index

selanjutnya) dalam memori. Begitu juga operasi pengurangan.

Asumsikan kita telah mendeklarasikan sebuah array float v[5], dan anggap elemen pertamanya berada pada lokasi 3000 di memori. Lalu kita deklarasikan sebuah variabel pointer *vPtr, ada dua cara untuk mengisi variabel pointer *vPtr dengan alamat dari elemen pertama array v, yaitu :

float *vPtr = v;

float *vPtr = &v[0];

Jika kita melakukan operasi aritmatika seperti

vPtr += 2;

dalam perhitungan aritmatika biasa, maka vPtr yang semula berisi 3000 menjadi 3000 + 2 = 3002, namun ini tidak berlaku pada pointer. Operasi aritmatika pada pointer di atas artinya adalah vPtr yang semula menunjuk pada v[0] sekarang menunjuk ke v[2].

Karena vPtr menunjuk alamat memori dari variabel v yang bertipe float, maka vPtr sekarang berisi 3008 (3000 + 2 * 4).

Contoh program (untuk dicoba)

Pertanyaan

3. Berapa selisih nilai (menggunakan heksadesimal) antar penunjuk dengan penunjuk+1? Hal apa yangmempengaruhi besarnya selisih nilai tersebut?

Untuk membantu, coba ganti tipe data variabel nilai dari int menjadi float.


Pointer pada Array

Pada array, pointer hanya perlu menunjuk pada alamat elemen pertama saja karena letak alamat array sudah berurutan pada memori.

Contoh program (untuk dicoba)

Pertanyaan

4. Tambahkan potongan kode program pada program di atas untuk membalik suatu kata/kalimat dengan menggunakan pointer!


Pointer pada Struct

Pointer dapat bertipe apa saja, bahkan tipe buatan kita sendiri.

Contoh program (untuk dicoba)


Latihan

Kalian tentu telah mengenal fitur T9 yang ada di handphone. Misalnya saat kita mengaktifkan T9 input yang bahasa inggris, lalu kita ingin mengetik school, maka kita cukup menekan 724665, maka otomatis akan keluar kata “school”.

Nah, sekarang kita coba menerapkan T9 didalam program latihan kita dengan menggunakan struct dan pointer tentunya.

Spesifikasi Input : Program menampilkan tulisan “Masukkan sebuah kalimat : “ kemudian program menunggu user memasukkan sebuah kalimat (tidak lebih dari 100 karakter).

Spesifikasi output : Program akan mengubah kalimat yang dimasukkan user menjadi rangkaian angka dengan menggunakan tabel T9.

T9

0

1

2

3

4

5

6

7

8

9

#

Data

0

Default 1

A B C 2

D E F 3

G H I 4

J K L 5

M N O 6

P Q R S 7

T U V 8

W X Y Z 9

Spasi

Program ini tidak case sensitif, artinya APA dengan apa atau Apa adalah sama.

Contoh:

Latihan 1

Input:

Masukkan sebuah kalimat : Aku ingin pulang

Output:

258#46446#785264

Latihan 2

Input:

Masukkan sebuah kalimat : Struktur Data 85 dapat A

Output:

78785887#3282#85#32728#2


Langkah-langkahnya:

1. Include kan file stdio.h dan ctype.h (ctype nantinya digunakan untuk memanggil fungsi toupper(char c)).

2. Buat struct Kata berisi 2 elemen yaitu elemen bertipe array of character (elemennya 100) dan jml_kata bertipe integer.

3. Buat sebuah variabel kata bertipe Kata dan sebuah variabel pointer p_kata bertipe Kata dan langsung mengacu pada alamat dari variabel kata.

4. Dalam fungsi main() buat variabel kalimat bertipe array of character dengan 100 elemen.

5. Selanjutnya ikuti code di bawah ini.

Lanjutkan program di atas agar sesuai dengan spesifikasi input dan output!

Hint :

Contoh Output Program :


DAFTAR PUSTAKA

Deitel, Harvey M dan Paul J Deitel. 2005. C++ How to Program, Fifth Edition. New Jersey: Prentice Hall.

Deshpande, P. S dan O. G. Kakde. 2003. C & Data Structures. Massachusetts : Dreamtech Press.

Solichin, Achmad. 2003. Pemograman Bahasa C dengan Turbo C. IlmuKomputer.Com.

Materi Struktur Data TI UKDW oleh Antonius Rachmat C. S.Kom, M.Sc.

Materi Praktikum Struktur Data 2007 oleh TIM Asisten Praktikum Struktur Data 2007.