Один ответ

A weather logger averages four temperature readings. What does this program print when you compile it with gcc and run it?

#include <stdio.h>

int main(void) {
    int temps[] = {4, 7, 5, 6};
    int count = sizeof temps / sizeof temps[0];
    int sum = 0;
    for (int i = 0; i < count; i++) {
        sum += temps[i];
    }
    printf("%d %d\n", count, sum / count);
    return 0;
}
Один ответ

What does this program print?

#include <stdio.h>
#include <string.h>

int main(void) {
    char city[20] = "Cluj";
    printf("%zu %zu\n", strlen(city), sizeof city);
    return 0;
}
Один ответ

A function tries to count the items in an array it receives. What does the program print in the sandbox, where pointers are 8 bytes and int is 4 bytes?

#include <stdio.h>

int count_items(int items[]) {
    return sizeof items / sizeof items[0];
}

int main(void) {
    int stock[] = {3, 0, 8, 2, 5, 1};
    printf("%d\n", count_items(stock));
    return 0;
}
Один ответ

Two arrays hold the same text. What does this program print?

#include <stdio.h>
#include <string.h>

int main(void) {
    char a[] = "OK";
    char b[] = "OK";
    printf("%d %d\n", a == b, strcmp(a, b) == 0);
    return 0;
}
Один ответ

True or false: after the declaration char code[4] = "SKU1"; the array code holds a properly terminated C string that is safe to pass to printf("%s", code).

Несколько ответов

A program declares int scores[5]; inside main. Which statements about this array are true? Select all that apply.

Один ответ

What does this program print?

#include <stdio.h>

int main(void) {
    char grade = 'B';
    printf("%c %d\n", grade + 1, 'C' - 'A');
    return 0;
}
Один ответ

What does this program print?

#include <stdio.h>

int main(void) {
    char word[] = "level";
    int n = 0;
    for (int i = 0; word[i] != '\0'; i++) {
        if (word[i] == 'e') {
            n++;
        }
    }
    printf("%d %zu\n", n, sizeof word);
    return 0;
}
Один ответ

What happens when you compile this program with gcc?

#include <stdio.h>

int main(void) {
    int a[3] = {1, 2, 3};
    int b[3];
    b = a;
    printf("%d\n", b[0]);
    return 0;
}
Один ответ

A timesheet stores hours for a five-day week but only fills the first two days. What does this program print?

#include <stdio.h>

int main(void) {
    int hours[5] = {8, 6};
    for (int i = 0; i < 5; i++) {
        printf("%d ", hours[i]);
    }
    printf("\n");
    return 0;
}