-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10 latihan-logika.c
More file actions
53 lines (43 loc) · 931 Bytes
/
10 latihan-logika.c
File metadata and controls
53 lines (43 loc) · 931 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <math.h>
int main() {
//Buatlah code untuk mencetak list angka berikut :149162536496481100
int a, kali;
for (a=1;a <= 10;a++) {
kali = a * a;
printf("%d\n", kali);
}
// Buatlah code program untuk menampilkan bilangan berikut
// a. 1 , 3 , 5 ,7 , 9 , 11, 13
printf("\n\n");
int b, z;
for (b=1;b <= 13; b++) {
if (b % 2 != 0) {
printf("%d\n", b);
}
}
// Or
printf("\nOr\n\n");
for (z = 1;z <= 13; z+=2){
printf("%d\n", z);
}
// b. 0.1 , 0.02 , 0.003 , 0.0004 , 0.00005
float c, n;
printf("\nBilangan disamping urutannya:\n");
for (c = 1; c <= 5; c++) {
n = c / pow(10, c);
printf(" %f,", n);
}
// c. 1, – 2 , 3 , – 4, 5 , -6 , 7
printf("\n\n");
int v, x;
for (x = 1;x <= 7;x++) {
if (x % 2 == 0) {
v = -x;
} else {
v = x;
}
printf("%d\n", v);
}
return 0;
}