51 lines
1.0 KiB
Plaintext
51 lines
1.0 KiB
Plaintext
|
|
int main() {
|
||
|
|
int x = -5;
|
||
|
|
int y = -10;
|
||
|
|
int z = 0;
|
||
|
|
|
||
|
|
printf("Testing negative numbers:\n");
|
||
|
|
printf("x = %d\n", x);
|
||
|
|
printf("y = %d\n", y);
|
||
|
|
printf("x + y = %d\n", x + y);
|
||
|
|
|
||
|
|
printf("\nTesting == operator:\n");
|
||
|
|
if (x == -5) {
|
||
|
|
printf("x == -5 is true\n");
|
||
|
|
}
|
||
|
|
if (x == y) {
|
||
|
|
printf("x == y is true\n");
|
||
|
|
} else {
|
||
|
|
printf("x == y is false\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
printf("\nTesting != operator:\n");
|
||
|
|
if (x != y) {
|
||
|
|
printf("x != y is true\n");
|
||
|
|
}
|
||
|
|
if (x != -5) {
|
||
|
|
printf("x != -5 is true\n");
|
||
|
|
} else {
|
||
|
|
printf("x != -5 is false\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
printf("\nTesting while loop with counter:\n");
|
||
|
|
int count = 0;
|
||
|
|
while (count != 5) {
|
||
|
|
printf("count = %d\n", count);
|
||
|
|
count = count + 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
printf("\nTesting while(1) with break condition:\n");
|
||
|
|
int i = 0;
|
||
|
|
while (1) {
|
||
|
|
printf("i = %d\n", i);
|
||
|
|
i = i + 1;
|
||
|
|
if (i == 3) {
|
||
|
|
printf("Breaking out of infinite loop\n");
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|