What is char?
This function is used to output statements.
What is printf?
int x = 7;
if (x > 5)
printf("A");
else
printf("B");
What is printed?
for (int i = 0; i < 3; i++) {
printf("Hi ");
}
This is the amount of times "Hi " is printed.
3
int x = 4;
printf("%d", x + 3);
What does it print
What is 7
This is how many bytes a double occupies
What is 8
Fill in the blank to read one character: scanf("___", &ch);
What is %c?
int x = 10;
if (x % 2 == 0 && x > 15)
printf("A");
else
printf("B");
This is printed.
What is A?
for (int i = 1; i <= 5; i++)
{
printf("%d ", i);
}
This is what's printed
What is 1 2 3 4 5 ?
char letter = 'G';
printf("%c", letter);
This is what it prints
What is G
This is how many bytes a char occupies
What is 1
scanf("%s", str);
int x = 8;
if (x > 5)
{
if (x < 10)
printf("A");
else
printf("B");
}
else
{
printf("C");
}
This is printed
What is A?
int x = 1;
while (x < 10)
{
x = x * 2;
}
printf("%d", x);
This is what's printed
What is 16?
int x = 7;
int y = 2;
printf("%d", x / y);
This is what it prints
What is 3
This is how to read in an integer n using scanf
This is the kind of variable type that does not require a % when reading in with scanf.
What is a string?
int x = 12;
if (x < 10)
{
printf("A");
}
else if (x % 5 == 2)
{
printf("B");
}
else
{
printf("C");
}
This is printed.
What is B?
int total = 0;
for (int i = 1; i <= 4; i++)
{
total = total + i;
}
printf("%d", total);
This is what's printed
What is 10?
int x = 10;
int y = 2;
int z = 4;
printf("%d", x % z / y);
What does it print
Given char word[12], this is the maximum number of (readable) characters the string can store.
11
Explain why " %c" sometimes works better than "%c" when reading in a character right after an integer
What is because characters do weird stuff with whitespace and scanf might read in the space instead of the character
int x = 14;
int y = 5;
if (x > 10)
{
if (x % y < 3)
{
y = y + 2;
if (x / y == 2)
printf("A");
else
printf("B");
}
else
{
printf("C");
}
}
else
{
printf("D");
}
What is C?
int x = 10;
while (x > 0)
{
printf("%d ", x);
x = x - 3;
}
This is what's printed
What is 10 7 4 1 ?
int total = 0;
for (int i = 1; i <= 5; i++)
{
if (i % 2 == 0)
total = total + i;
}
printf("%d", total);
This is what it prints
What is 6