דילוג לתוכן
מבחן 10 שאלות

Variables and Data Types in C#

שאלות 10

מפתח התשובות מוצג למורים מחוברים.

  1. רב־ברירהc#data typesinteger divisionvariable assignment

    Integer division

    What value is stored in x after the statement int x = 7 / 2; executes in C#?

    1. 3.5

    2. 2

    3. 3

    4. 4


    Think about what happens when two int operands are divided. Does the result keep a fractional part?
  2. רב־ברירהc#data typessigned integers64-bit integer

    Signed 64-bit integer type

    Which C# built-in integral type stores a signed 64-bit integer?

    1. long

    2. int

    3. short

    4. uint


    The int type is 32 bits. Look for the keyword that refers to a larger signed integer.
  3. רב־ברירהc#negative numbersremainder operatormodulo

    Remainder with a negative divisor

    What is the result of the expression 7 % -3 in C#?

    1. 1

    2. 2

    3. -1

    4. -2


    The % operator returns the remainder of integer division. Check how many times 3 fits into 7 and what is left over.
  4. רב־ברירהc#increment operatorspost-incrementpre-increment

    Post and pre increment

    After int a = 5; is executed, what value is stored in b by the statement int b = a++ + ++a;?

    1. 10

    2. 13

    3. 12

    4. 11


    Work through the operands from left to right. The postfix operator uses the current value before incrementing, while the prefix operator increments first.
  5. רב־ברירהc#constantsvariable declarationconst keyword

    Declaring a constant

    Which declaration correctly creates a constant named Pi of type double in C#?

    1. constant double Pi = 3.14159;

    2. double const Pi;

    3. const double Pi = 3.14159;

    4. const Pi double = 3.14159;


    C# uses a specific keyword to mark a value as unchangeable. The keyword goes before the type, and a constant must be given its value when declared.
  6. רב־ברירהc#var keywordtype inferenceimplicit typing

    Implicit typing with var

    In C#, if you write var x = 3.0;, what is the compile-time type of x?

    1. int

    2. double

    3. decimal

    4. float


    A real number literal without a suffix has a default floating-point type. Consider which one the compiler chooses for a literal such as 3.0.
  7. רב־ברירהc#numeric typesdecimal typefinancial calculations

    Type for exact monetary values

    Which C# numeric type is generally preferred for financial calculations that require exact decimal representation?

    1. int

    2. double

    3. decimal

    4. float


    Binary floating-point types cannot represent many decimal fractions exactly. Look for the type designed for base-10 precision with a large number of significant digits.
  8. רב־ברירהc#divisionfloating-pointconsole output

    Floating-point division output

    What is printed by the statement Console.WriteLine(10 / 4.0); in C#?

    1. 2.0

    2. 2

    3. 2.5

    4. 3


    Because one operand is a double, the division is performed in floating-point arithmetic rather than integer arithmetic.
  9. רב־ברירהc#logical operatorsboolean expressionsoperator precedence

    Logical operators

    What is the value of the boolean expression (5 > 3) && (2 == 4) in C#?

    1. true

    2. 1

    3. 0

    4. false


    The && operator is true only when both of its operands are true. Evaluate each comparison separately first.
  10. רב־ברירהc#data typescharacterschar literal

    Type of a character literal

    In C#, what is the type of the literal 'A' written with single quotes?

    1. int

    2. char

    3. string

    4. byte


    Single quotes enclose one UTF-16 code unit. Double quotes, by contrast, create a sequence of characters.

פרטים

A test on declaring variables, basic data types and simple operations in the C# language for high school students.
מקצועות
c#
קהל יעד
תיכון · כיתות י׳–י״א
רמת קושי
6 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
הושלם על ידי AI
מה שמסומן בניצוץ נוסף על ידי AI.
נוצר באמצעות AI
Claude Haiku 5.5
נוצר

תגובות

  1. אין תגובות עדיין.
© כל הזכויות שמורות