-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cdx
More file actions
37 lines (35 loc) · 796 Bytes
/
test.cdx
File metadata and controls
37 lines (35 loc) · 796 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
/* A program to compute factorials */
/*int fact( int n) {
if (n <= 1) {
return 1;
} else {
return n*fact(n-1);
}
}
void main() {
int x;
string s = "hello world!";
x = 1;
while (x <= 10) {
write(x);
write(fact(x));
writeln();
x = x + 1;
}
}*/
// A calculator
int main() {
int operation = input("Enter a number for operation 0 for +, 1 for -, 2 for *, 3 for /");
int first = input("Enter first number: ");
int second = input("Enter second number: ");
if (operation == 0) {
print(first + second);
} else if (operation == 1) {
print(first - second);
} else if (operation == 2) {
print(first * second);
} else {
print(first / second);
}
return 0;
}