-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct.cpp
More file actions
33 lines (25 loc) · 757 Bytes
/
Copy pathstruct.cpp
File metadata and controls
33 lines (25 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
struct hewan {
int umur;
const char *nama;
};
typedef struct
{
int x, y, luas, keliling;
} persegi_panjang;
int main() {
std::cout << "CPP Teaching Copyright (C) 2021 EmptyWork" << std::endl;
hewan ikan;
ikan.nama = "Ikan Emas";
ikan.umur = 17;
std::cout << "Nama hewan: " << ikan.nama << std::endl;
std::cout << "Umur hewan: " << ikan.umur << std::endl;
persegi_panjang pertama;
pertama.x = 7;
pertama.y = 8;
pertama.luas = pertama.x + pertama.y;
pertama.keliling = 2 * (pertama.x + pertama.y);
std::cout << "Ukuran dari Pertama: " << sizeof(pertama) << std::endl;
std::cout << "Luas dari Pertama: " << pertama.luas << std::endl;
std::cout << "Keliling dari Pertama: " << pertama.keliling;
}