Type Casting & Integer Promotion

This C quiz covers explicit casts and the implicit conversions C performs on its own, like integer promotion and the usual arithmetic conversions. You will predict results where the type of an expression changes the answer and spot the classic signed/unsigned trap.

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

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

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

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

Вопрос 1 из 10

What does this print?

#include <stdio.h>

int main(void) {
    int a = 7, b = 2;
    double r = (double)a / b;
    printf("%.1f\n", r);
    return 0;
}
Показать ответ

A. 3.5 The cast applies to a before the division, so it is double / int, and b is converted to double too. The division keeps the fraction: 3.5.

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

  • Casting int to double before or after a division
  • Truncation when converting floating point to int
  • Integer promotion of char and short in expressions
  • Comparing signed and unsigned values
  • Overflow before widening

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

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

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

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

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