Квиз по C: Pointer Arithmetic

This C quiz tests how pointer arithmetic works: adding to a pointer moves by whole elements, subtracting two pointers counts elements between them, and * and ++ combine in ways that trip people up. You need to know basic pointers already.

Средний 10 вопроса ~6 минуты Проходной балл: 80% C17

Выберите режим

Вы играете как гость: войдите, чтобы сохранить XP и серию.

Пример вопроса

Вопрос 1 из 10

What does this print?

#include <stdio.h>

int main(void) {
    int a[] = {10, 20, 30, 40};
    int *p = a;
    p += 2;
    printf("%d\n", *p);
    return 0;
}
Показать ответ

C. 30 p starts at a[0], and adding 2 moves it two elements forward, to a[2]. Pointer arithmetic counts in elements, so the result is 30, not something 2 bytes further.

Что проверяет этот квиз

  • p + n moves by n elements, not n bytes
  • *(p + 1) vs *p + 1
  • *p++ vs (*p)++
  • Subtracting pointers into the same array
  • The one-past-the-end pointer and what is not allowed

Частые вопросы

Нужен ли аккаунт?

Нет. Играть может любой. Войдите, чтобы сохранять XP, серию, значки и историю.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.