-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction5
More file actions
37 lines (30 loc) · 811 Bytes
/
function5
File metadata and controls
37 lines (30 loc) · 811 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
34
35
36
37
//function5_variable_statis
#include <iostream>
using namespace std;
void saya_ingat(); //prototipe fungsi
void saya_ingat_2(); //prototipe fungsi
int main()
{
int mamamia = 50;
saya_ingat();
saya_ingat();
saya_ingat();
cout<<"main () : mamamia = " <<mamamia<< endl;
saya_ingat_2();
saya_ingat_2();
saya_ingat_2();
cout<<"main () : mamamia = " <<mamamia<< endl;
}
// pada fungsi berikut mamamia didefinisikan sbg variabel statis
void saya_ingat()
{
static int mamamia=77; //variabel statis
mamamia++; //naikkan sebesar 1
cout<<"saya_ingat() : mamamia = "<< mamamia << endl;
}
void saya_ingat_2()
{
int mamamia=77; // bukan variabel statis
mamamia++; //naikkan sebesar 1
cout<<"saya_ingat_2() : mamamia = "<< mamamia << endl;
}