Preview

PT 1420 Assignment 3

Good Essays
Open Document
Open Document
676 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
PT 1420 Assignment 3
Short answers
5. What two things must you normally specify in a variable declaration?
You must specify the variable type and an identifier. int n; // type - int, identifier - n 6. What value is stored in uninitialized variables? is a variable that is declared but is not set to a definite known value before it is used.
Algorithm workbench
3. Write assignment statements that perform the following operations with the variables a, b, and c.
a. Adds 2 to a and stores the result in b
b. Multiplies b times 4 and stores the result in a
c. Divides a by 3.14 and stores the result in b
d. Subtracts 8 from b and stores the result in a
Assignment statements that perform operations with the variables a, b, and c* (*Actually none of these operations involves the variable c at all... is this an error, or a 'trick answer'?): b = a + 2 a = b * 4 b = a / 3.14 a = b – 8
4. Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2. What value will be stored in result in each of the following statements?
a. Set result = x + y
b. Set result = z * 2
c. Set result = y / x
d. Set result = y – z result = x++ - y;
Answer -4 result = 4 – 8 = -4 result = ++w + y;
Answer
w = w + 1 = 5 + 1 = 6 result = 6 + 8 = 14
5. Write a pseudocode statement that declares the variable cost so it can hold real numbers.
Declare Real price= 0.00
Display "the original price."
Input item original price
Display "price"
6. Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0.
Declare Real price= 0.00
Display "the original price."
Input item original price
Display "price"
7. Write a pseudocode statement that assigns the value 27 to the variable count. count := 27
8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total.
/*Declare variables
Total (number (3)) = 0
A (number (2)) =10
B (number (2)) =14
Begin

You May Also Find These Documents Helpful

  • Satisfactory Essays

    = z) return true; else return false; } Problem 5 a. Output: 720 b. Output: 0 c. Output: 71 d. Output: 362880 Problem 6 a. Output: “Take Programming I.” b. Output:…

    • 188 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    The free group with two generators a and b is composed of all finite strings that are formed from the four symbols a, a−1, b and b−1 given that no a is directly next to an a−1 and no b is directly next to a b−1. Two such strings can be concatenated and converted into a string of this type by repeatedly replacing the "forbidden" substrings with the empty string. For example: abab−1a−1 concatenated with abab−1a yields abab−1a−1abab−1a, which contains the substring a−1a underlined in the example, and so the “forbidden” string gets cancelled and reduced to abab−1bab−1a, which again contains the substring b−1b underlined in the example, which then gets reduced to abaab−1a. It can be checked that the group formed from the set of those strings with…

    • 493 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    b. Include the function written in Exercise 2a in a working program. Make sure your function…

    • 720 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    No the supervisor isn't right because Mark and Jean can fill the pool less than ten hours.…

    • 104 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    PT1420 Unit 8 Lab 8

    • 365 Words
    • 2 Pages

    Calculating a Running Total, page 201): Asks for input of a number 5 times then adds all numbers into one total sum, example 2,4,6,8,10 = 30…

    • 365 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    /*question number 1*/ Code: int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What number will z in the sample code above contain? Choice 1 5 Choice 2 6 Choice 3…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Satisfactory Essays

    3. Using the keypad, type the numbers across the table in exercise C and exercise D into the table (box) provided below.…

    • 625 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    1) Numbers can be represented in binary (using 2 symbols 0 and 1) and hexadecimal ( 16 symbols…

    • 480 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    2.Write a program to (a) display a “?” (b) read two decimal digits whose sum less than 10 (c) display them and their sum on the next line. Page: 80…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The variable can be more than one number.. as long as the statement is true…

    • 351 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    It210 Appendix F

    • 372 Words
    • 3 Pages

    4. The calculation should be executed only after all the valid input values are provided.…

    • 372 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Ordinal level question & content validity: This question has good content validity because it shows how much school a child is missing and is used to formulate the rate of absenteeism.…

    • 777 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Java Chapter 2 Quiz

    • 2047 Words
    • 9 Pages

    4. The ____ is normally considered the standard output and standard input devices, and usually refer to…

    • 2047 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    Pt1420 Assignment 1

    • 610 Words
    • 3 Pages

    What central claim is being made? (The claim is generally made in an explicit thesis statement.)The claim was that the internet is not safe because it can share your personable information easily. And allow others to look up your information.…

    • 610 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    UNIT 2

    • 470 Words
    • 3 Pages

    4.) Write assignment statements that perform the following operations with the variables a, b, and c:…

    • 470 Words
    • 3 Pages
    Satisfactory Essays