unit 3

Satisfactory Essays
313 Words
Grammar
Plagiarism
Writing
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

Pt1420 week 2

• 320 Words
• 3 Pages

Display “425-299-6474 Display “Intro to Programing” 4. Total Purchase 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

5. 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

* set result= x+y= 4+8 * set result=z*2= 2*2 * set result= y/x= 8/4 * set result= y-z= 8-2…

• 1062 Words
• 8 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
• Good Essays

Friction

• 771 Words
• 4 Pages

ENC1102 SUMMER II 2013 FICTION EXAM 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

unit 4

• 691 Words
• 4 Pages

5. In most languages, where does a local variable’s scope begin and end? It begins at the variables declaration within a module and it ends at the end of the module in which the variable is declared.…

• 691 Words
• 4 Pages
Satisfactory Essays
• Good Essays

a. 4 b. 7 c. true d. false 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

Product = number * 10 Display “Your number is”, product End While 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

C++ Midterm

• 2831 Words
• 12 Pages

#include <iostream> using namespace std; int main() { int value = 3; value = value - 2 * value;…

• 2831 Words
• 12 Pages
Good Essays
• Satisfactory Essays

Week1 Exercises

• 499 Words
• 2 Pages

z / x = 3 e) cout << “2 times “ << x << “ = “ << 2 * x << endl;…

• 499 Words
• 2 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
• Satisfactory Essays

Checkpoint 2

• 294 Words
• 2 Pages

CheckPoint Chapter 2 Programming Problem 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
• Satisfactory Essays

Ch. 2 Modules

• 381 Words
• 3 Pages

– f. costOfDoingBusinessThisFiscalYear – g. costYear2012 – h. 2012YearCost – 2. Assume that cost = 10 and price = 12. What is the value of each of the following expressions?…

• 381 Words
• 3 Pages
Satisfactory Essays
• Good Essays

1 2 3 4 5 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

Function name: even Return type: bool Parameter list: int n Statements in the body: if (n % 1 == 0)…

• 823 Words
• 4 Pages
Satisfactory Essays