For and While Loops
Strings
Functions
Arrays
Pointers
100

Proper syntax for writing a for-loop that runs 5 times

What is: for (int i = 0; i < 5; i++)?

100

How we know we have reached the end of a string

What is the null terminator OR What is /0?

100

int sigma(float beep, char boop) will return what type of variable

What is an integer?

100

The numerical value of the index that all arrays begin at

What is 0?

100

A pointer stores this

What is a memory address?

200

Proper syntax for a while loop that runs until variable int end equals 2

What is: while (int end != 2)?

200

Proper syntax for declaring a string that holds the word "jorts"

What is: char arr[6] = "jorts" ?

200
The function parameter for circlePerim, which takes in a whole number radius and returns the perimeter as a decimal

What is: float circlePerim(int radius) OR double circlePerim(int radius)?

200

How can I access the fifth element of an integer array arr and change it to equal 67?

What is "arr[4] = 67"?

200

Proper syntax for declaring a pointer p that points to a float x

What is: float *p = &x ?

300

In what case is it better to use for loops, and in what case is it better to use while loops

What is "For loops are better for things that need to run a specific number of times, whereas while loops are better for running until a certain condition is met"?

300

What does the function strcat() do

What is: Concatenate (aka combine) two strings together, putting the second at the end of the first? 

300

Will the following code compile, if so, what will be printed?

#include <stdio.h>

int main(void)
{
  int my_number = 5;
  printf("The value of my_number is: %d\n", my_number);
  {
    int my_number = 10;
  }
  printf("The value of my_number is: %d\n", my_number);
  return 0;
}

What is yes, and 

"The value of my_number is: 5 

The value of my_number is: 5"?

300

Proper syntax for declaring a double array that holds int size number of currently unknown elements

What is: double arr[size] ?

300

The way to access the value stored inside the variable a pointer p is pointing to

What is *p OR dereference operator?

400

How many times will "bepis" print?

for(int i = 0; i < 5; i++) {

     for (int j = i; j < 3; j++) {

          for(int k = 1; k < 4; k++) {

                printf("bepis\n");

          }

}

What is 18 times?

400

How many characters does the following string contain?

char string[] = "I am the Lorax,\nI speak for the trees.\n\0"

What is 40?

400

What will main print?

void add_num(int x, int y)    {

  x = x + y;

}

int main(void)    {

  int x = 10;

  printf("At first x was %d\n", x);

  add_num(20, 10);

  printf("Now x is %d\n", x);

  add_num(x, 10);

  printf("While x is now %d\n", x);

  return 0;

}

What is:

"At first x was 10

Now x is 10

While x is now 10"

400

Does the code compile, and if so, what does it print

void increase_by_one(int array[], int length)   {
  for (int i = 0; i < length; i++)   {
    array[i]++;
  }
}
int main(void)    {
  int array[5] = {1, 2, 3, 4, 5};
  increase_by_one(array, 5);
  for (int i = 0; i < 5; i++)    {
    printf("%d\n", array[i]);
  }
  return 0;
}

What is yes, and "

2

3

4

5

6"?

400

How can we swap the values of two variables using pointers only

What is: "

void swap(int *a, int *b) {

int temp = *a; 

*a = *b;

*b = temp;   

 }"?

500

How to write a while loop that ends when it reaches the end of a string str OR an when an int lele equals or is greater than 20, but is always guaranteed to run at least once?


do {

// thing

i++;

} while ((str[i] != /0) || (lele < 20))

500

How to find the length of a string str without using strlen() or any other pre-made function (write the code needed!)

What is:

int sum = 0;

while(str[i] != /0)    {

sum++;

i++;

}

500

Using functions from the math library, create a function that returns the float value of the distance between two points, whose coordinates are also given as floats

Hint: There a few different ways of doing this -- but there is a way you can write it using only one line of code within your function!

What is:"

double distance_between_points(float x1, float y1, float x2, float y2)
{
  return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}"?

500

Create a function that takes two integer arrays, array1 and array2, and the length of array1, that copies the contents of array1 into array2

Assume that array2 has at least as many elements as array1

What is: "

void copy_array(int *array1, int *array2, int length)    {
  for (int i = 0; i < length; i++)   {
    array2[i] = array1[i];
  }
}"?

500

Does this compile, and if so, what does it print?


int main(void)  {
    int n = 43;
    printf("%p\n", &*&*&*&*&*&*&n);
    return 0;
}

What is yes, it prints 43?