-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathifstmnt.c
65 lines (53 loc) · 1.34 KB
/
ifstmnt.c
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
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
// for testing only - do not change
void getTestInput(int argc, char* argv[], int* a, int* b)
{
if (argc == 3) {
sscanf(argv[1], "%d", a);
sscanf(argv[2], "%d", b);
}
}
int main(int argc, char* argv[])
{
// the two variables to compare - change these values to test your code
int a = 0;
int b = 6;
// for testing only - do not change
getTestInput(argc, argv, &a, &b);
// equal operator - this one is done
if (a == b)
printf("true: %d == %d\n", a, b);
else
printf("false: %d == %d\n", a, b);
// complete the rest below by adding if statements
// not equal operator
if (a != b)
printf("true: %d != %d\n", a, b);
else
printf("false: %d != %d\n", a, b);
// greater than
if (a > b)
printf("true: %d > %d\n", a, b);
else
printf("false: %d > %d\n", a, b);
// greater than or equal
if (a >= b)
printf("true: %d >= %d\n", a, b);
else
printf("false: %d >= %d\n", a, b);
// and
if (a == 0 && b == 0)
printf("true: %d == 0 && %d == 0\n", a, b);
else
printf("false: %d == 0 && %d == 0\n", a, b);
// or
if (a == 0 || b == 0)
printf("true: %d == 0 || %d == 0\n", a, b);
else
printf("false: %d == 0 || %d == 0\n", a, b);
// not equal to 0
if (a != 0)
printf("true: !(%d == 0)\n", a);
else
printf("false: !(%d == 0)\n", a);
}