Quick Test 18: Arrays and Structs

1. What is the difference between an array and a struct?

An array can store only countable things, whereas a struct can store anything.
A struct can only store countable things, whereas an array can store anything.
Arrays are for combining variables of different type, structs store variables of the same type.
Structs are for combining variables of different type, arrays store variables of the same type.

float maximum(float a, b)
{
  float max;

  if (a>b)
    max = a;
  else 
    max = b;
 .....
}
2. How to let this function return the value of max to the calling instruction?

Nothing, this is done automatically.
return (max);
maximum = max;
This function has no output and will not return anything

struct {
  struct {
    float z[10];
    int i[3];
  } x;
  struct {
    float r;
    double p;
  } y;
} a[10];

3. How to assign a value of 0 to (the first) i of this program?

4. We want to make a database with the information of 1000 students with their name and year. We can do this best with a variable

struct {
            int number;
            char name[20];
            int year;
    } a;
struct {
            int number;
            char name[20];
            int year;
    } a[1000];
struct {
        int number[1000];
        char name[1000][20];
        int year[1000];
   } a;
struct {
        int number[1000];
        char name[1000][20];
        int year[1000];
   } a[1000];