- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
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.
Domanda di esempio
Domanda 1 di 10What 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;
}
Mostra la risposta
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.
Cosa copre questo quiz
- Casting
inttodoublebefore or after a division - Truncation when converting floating point to
int - Integer promotion of
charandshortin expressions - Comparing signed and unsigned values
- Overflow before widening
Domande frequenti
Serve un account?
No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.
Posso rifarlo?
Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.