Small Basic Arithmetic and Variables Quiz
5 Questions
7 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which arithmetic operator is not used in Small Basic?

  • \ (correct)
  • /
  • *
  • +
  • What is the output of the expression 6 + 50 * 2?

  • 106
  • 5
  • 22
  • 112 (correct)
  • What is the correct method to read a numeric value during program execution in Small Basic?

  • ReadValue()
  • Read()
  • ReadNumber() (correct)
  • Number()
  • Which symbol is used for inserting comments in a Small Basic program?

    <p>//</p> Signup and view all the answers

    What will be the output of Math.Remainder(30, 8)?

    <p>6</p> Signup and view all the answers

    Study Notes

    Arithmetic Operators

    • Small Basic uses the following arithmetic operators: +, -, *, /, \
    • The \ operator is used for integer division
    • The operator * is used for multiplication
    • The operator + is used for addition
    • The operator / is used for division
    • The operator - is used for subtraction
    • The order of execution of arithmetic operators is from left to right

    Variables

    • Variables are used to store data in Small Basic
    • Variables can be named using letters, numbers, and underscores
    • Variable names must start with a letter
    • There are two types of variables in Small Basic:
      • Local variables: These are defined within a specific block of code and can only be accessed within that block.
      • Global variables: These are defined outside of any block of code and can be accessed from anywhere in the program.
    • The ReadNumber() method reads a numeric value from the user during program execution.

    Comments

    • Comments are used to explain code and are ignored by the compiler.
    • Comments can be added to a program using the // symbol.

    WriteLine() and Write() Methods

    • The WriteLine() method displays text on a new line.
    • The Write() method displays text on the same line as the previous output.

    Conditional Statements

    • Conditional statements allow you to control the flow of your program based on certain conditions.
    • The If-Then statement executes a block of code if a condition is true.
    • The If-Then-Else statement executes one block of code if a condition is true and another block of code if the condition is false.
    • The If-Then-ElseIf statement allows you to check multiple conditions and execute different blocks of code based on the true condition.

    Operators

    • The >= operator checks if a value is greater than or equal to another value.
    • The > operator checks if a value is greater than another value.

    Program Example

    • To count the number of students under 14 years old who bring lunchboxes from home, the following steps are followed:
      • Declare a variable to store the count of students under 14.
      • Use a loop to ask each student their age and whether they bring lunch from home.
      • If the student's age is under 14 and they bring lunch from home, increment the count variable.
      • Display the total count of students.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of arithmetic operators and variables in Small Basic. This quiz will cover the usage of various operators, types of variables, and the importance of comments in programming. Dive in to see how well you understand these foundational concepts!

    Use Quizgecko on...
    Browser
    Browser