F129 Introduction To Programming Test 1

10 Questions | Total Attempts: 239

SettingsSettingsSettings
Please wait...
Programming Quizzes & Trivia

This test will ask you questions up to Chapter 6 of the study guide


Questions and Answers
  • 1. 
    The result of this expression 3 + 5 * 2 + 4 is
    • A. 

      20

    • B. 

      64

    • C. 

      17

    • D. 

      None of the above

  • 2. 
    Mention 4 types of data types and give an example for each.
  • 3. 
    Call-by-value is
    • A. 

      When you declare a variable of some certain data type

    • B. 

      When a variable's value is copied into a parameter when calling some method

    • C. 

      When you refer to a variable

    • D. 

      When you assign a value to a variable

  • 4. 
    Give the truth table (decision table) of the AND operator
  • 5. 
    The AND and OR logical operators take two operands one on each side. What are the data types of these operands?
    • A. 

      String

    • B. 

      Integer

    • C. 

      Character

    • D. 

      Boolean

    • E. 

      None of the above

  • 6. 
    The data type of the following expression squareroot(14) is
    • A. 

      Integer

    • B. 

      String

    • C. 

      Real

    • D. 

      3.741

  • 7. 
    What is the data type of "hello "+name, where name is some variable storing the user's name
    • A. 

      String

    • B. 

      Character

    • C. 

      Integer

    • D. 

      None of the above

  • 8. 
    How would you end a module which gives back the addition of 3 numbers. The module so far looks like thisCalculateSum(Integer a, Integer b, Integer c)   Integer sum = a + b + c
    • A. 

      End

    • B. 

      Exit

    • C. 

      Return sum

    • D. 

      None of the above

  • 9. 
    How would you call the module from the Control module to give you back the result of the sum, using the module mentioned in the previous question. So far the Control module looks like this:Control   Print "Give me three numbers"   Integer x   Enter x   Integer y   Enter y   Integer z   Enter z
    • A. 

      Process CalculateSum(x,y,z)

    • B. 

      Process CalculateSum(a, b, c)

    • C. 

      Process CalculateSum(*x,*y,*z)

    • D. 

      Process CalculateSum(*a, *b, *c)

    • E. 

      None of the above

  • 10. 
    Write a small program that asks the user for two numbers and you need to display back the biggest number of the two numbers that he gives you. Ideally you would use modules. Remember that you always have the Control module, then we usually have three other modules, one which caters for the input, another for the calculation, and another for the output. Also remember that in pseudo code you use Print to output on the user's screen, and Enter to wait for input from the user's keyboard. Also remember to declare the variable data type before using a variable.