Preview

unit 3

Satisfactory Essays
Open Document
Open Document
313 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
unit 3
Short Answer 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?
Some languages assign a default value as 0 to uninitialized variables. In many languages, however, uninitialized variables hold unpredictable values.
Algorithm Workbench
3. Write assignment statements that perform the following operations with the variables a, b, and c.
Adds 2 to a and stores the result in b.
Multiplies b times 4 and stores the result in a
Divides a by 3.14 and stores the result in b
Subtract 8 from b and stores the result in a
4. Assume the variables result, w, x, y , and z are 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?
Set result = x + y
Set result = z* 2
Set result = y / x
Set result = y – z
5. Write a pseudocode statement that declares the variable cost so it can hold real number.
6. Write a pseudocode statement that declares the variable total so it can hold real integers. Initialize the variable with the value 0.
7. Write a pseudocode statement that assigns the value of 27 to the variable count.
8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total.
9. Write a pseudocode statement that subtracts the variable Down Payment from the variable total and assigns the result to the variable due.
10. Write a pseudocode statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable total fee.

Programming Exercises

6. Sales Tax 8. Tip, Tax, and Total
Design a program that calculates the total amount of meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15% tip and 7% sales tax. Display each of these amounts and the total.

You May Also Find These Documents Helpful

  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    If the user does not enter a numeric value the program should prompt for a numeric value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 week 2

    • 320 Words
    • 3 Pages

    A customer in a store is purchasing five items. Design a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total. Assume the sales tax is 6 percent.…

    • 320 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Checkpoint 2

    • 294 Words
    • 2 Pages

    The manager of the Supermarket would like to be able to compute the unit price for the product sold here. To do this, the program should input the name and price of an item and its weight in pounds and ounces.…

    • 294 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Nothing

    • 1097 Words
    • 5 Pages

    8) Write (in the same base) the counting numbers just before and just after 1044 five. A) 1043five, 1045 five C) 1043five, 1111 five B) 1042five, 1101 five D) 1043five, 1100 five…

    • 1097 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Ch. 2 Modules

    • 381 Words
    • 3 Pages

    1. Explain why each of the following names does or does not seem like a good variable name to you.…

    • 381 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    6. Assuming the variable q has been assigned the value 3, which of the following statements prints XXX? A.…

    • 765 Words
    • 4 Pages
    Good Essays
  • Good Essays

    PT1420 Assign7

    • 685 Words
    • 4 Pages

    2. Design a Do-While loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user if he or she wishes to perform the operation again. If so, the loop should repeat, otherwise it should terminate.…

    • 685 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Patient Account Tables

    • 1133 Words
    • 5 Pages

    (b) Add a constraint that Fee should not be less than US$100 and can be null.…

    • 1133 Words
    • 5 Pages
    Good Essays
  • Good Essays

    C++ Midterm

    • 2831 Words
    • 12 Pages

    What is the value inside the "value" variable at the end of the given code snippet?…

    • 2831 Words
    • 12 Pages
    Good Essays
  • Good Essays

    Friction

    • 771 Words
    • 4 Pages

    Choose the best answer that completes each statement. There is only ONE correct answer for each. Please mark your answers clearly by highlighting your answer. Each multiple choice question is worth one point.…

    • 771 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Assignment 4

    • 634 Words
    • 3 Pages

    #3. Suppose three values (x, y, and z) are stored in a machine's memory. Describe the sequence of events (loading registers from memory, saving values in memory, and so on) that lead to the computation of x + y + z. How about (2x) + y?…

    • 634 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Programming Homework

    • 823 Words
    • 4 Pages

    B) What do you think the purpose of function? Write appropriate comments into the function to reflect this purpose.…

    • 823 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    6) Write a program to calculate the factorial of a given number. 7) Write a program to calculate sum of squares of cubes of first n natural numbers. 8) Write a program to reverse the given number. 9) Write a program to calculate mn value using do-while loop. 10) Write a program to check whether the given number is a palindrome or not. 11) Write a program to check whether the given number is an Amstrong number or not. 12) Write a program to check whether the given number is a perfect number or not. 13) Write a program to print the following format. * * * * *…

    • 1735 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    1.1 Write a program to calculate the final mark of students and to display the marks in a listbox using sequential files. The input values (icasno, name, ca1, ass, ca2 & exam marks) must be taken from the sequential file…

    • 976 Words
    • 8 Pages
    Satisfactory Essays
  • Satisfactory Essays

    13.a) What is the difference between an algorithm and pseudocode? Also write an Algorithm and pseudocode for solving a quadratic equation. (16)…

    • 2874 Words
    • 12 Pages
    Satisfactory Essays