Checkpoint 1.3.1. Simple Conditionals.
Given this code, what does it print to the screen?
int x;
x = 10;
if (x < 10) {
printf("Sharks\n");
} else {
printf("Jets\n");
}
int x;
x = 10;
if (x < 10) {
printf("Sharks\n");
} else {
printf("Jets\n");
}
int x;
x = 10;
if (x < 10) {
printf("Apple");
} else if (x < 20) {
printf("Banana");
} else if (x < 30) {
printf("Cherry");
} else {
printf("Durian");
}
int x;
scanf("%d",&x);
if (x % 2 == 0) {
printf("x is divisible by 2\n");
} else if (!(x % 3)) {
printf("x is divisible by 3\n");
} else (x % 5 == 0) {
printf("x is divisible by 5\n");
}
int x;
scanf("%d",&x);
if (!x) {
printf("Apple\n");
} else if (x > 0) {
printf("Banana\n");
} else if (x < 0) {
printf("Cherry\n");
} else {
printf("Dragonfruit\n");
}
int temp, humidity;
scanf("%d", &temp);
scanf("%d", &humidity);
if (cond) {
printf("The weather looks good today!\n");
}
int i;
for (i = 1; i < 5; i++) {
printf("Hello\n");
}
int i;
int x;
x = 7;
for (i = 0; i < x; i++) {
printf("Hello\n");
}
int i;
for (i = 0; i < -10; i++) {
printf("Hello\n");
}
int i;
for (i = 1; i < 9; i+=2) {
printf("Hello\n");
}
int i;
for (i = 5; i >= 0; i--) {
printf("Hello\n");
}
int i;
i = 3;
while (i > 0) {
printf("tweet\n");
i--;
}
int i;
for (i = 100; i <= 200; i+=5){
printf("%d\n", i);
}
int i;
for (i = 0; i < 10; i--) {
printf("moo\n");
}
int i;
while (i < 10) {
printf("%d\n",i);
i++;
}
True.
False.
int love;
love = 0;
while (love < 10) {
printf("%d\n", love);
}
int i;
for (i = 0; i < 10; i++) {
printf("Hello\n");
}
int i;
i = 5;
while (i < 10) {
printf("yay!\n");
i = i + 2;
}
int x, y;
x = 10;
y = 20;
if ((x >= 10) && (y < 30)) {
printf("roar\n");
y++;
}
int x, y;
x = 10;
y = 20;
while ((x >= 10) && (y < 30)) {
printf("roar\n");
y++;
}
True.
False.