100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Summary

Summary Programming Logic and Design Ch 2

Rating
-
Sold
-
Pages
5
Uploaded on
15-11-2025
Written in
2025/2026

This document provides an in depth and thorough summary of chapter 2 of Programming Logic and Design. It is ready for exam and tests. Everything is laid out as it is in the textbook. All needed information is provided in short. It is written in an easy to study format and reads easy. I got distinctions in exams and tests.

Show more Read less
Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Course

Document information

Summarized whole book?
No
Which chapters are summarized?
2
Uploaded on
November 15, 2025
Number of pages
5
Written in
2025/2026
Type
Summary

Subjects

Content preview

Chapter 2

Declaring and using variables and constants
 Data type- a classification that describes the following:
 What values can be held by the item
 How item is stored in computer memory
 What operations can be performed on the item
 Numeric- data that consists of numbers/decimals, arithmetic operations performed
 Integer values- whole numbers / Floating point values (real numbers) -
decimal numbers
 String- data items that are non-numeric, cannot be used in arithmetic operations
 Numeric constant -Contains numbers that does not change
 String constant (Alphanumeric values) - Enclosed in quotation marks, contains characters
and numbers
 Variable -named memory locations, content can vary
 Numeric variable- holds digits, performs mathematical operations
 String variable- holds text, letter, special characters
 Declaration is a statement that provides a variable's:
 Data type
 Identifier (variable’s name)
 Optionally, an initial value
 Type-safety -Prevents assigning values of an incorrect data type
 Identifier- variable name
 Choose reasonable and descriptive name for variables
 Most languages allow letters and digits
 Some languages allow hyphens
 Reserved keywords are not allowed (num/string)
 Variable names- case sensitive
 Must be one word
 Must start with a letter
 Should have appropriate meaning
Variable Naming
Camel casing (lower) hourlyWage Snake casing hourly_wage
Pascal casing (upper) HourlyWage Underscore casing Hourly_Wage
Hungarian notation numHourlyWage Kebob casing hourly-wage


 Assignment statement- first calculates myNumber * 2, then stores computed value in
myAnswer
 set myAnswer = myNumber * 2
 Assignment operator
 Binary operator- requires two operands - one on each side

,  Operates from right to left, right-associativity or right-to-left associativity
 The result to the left of an assignment operator is called a Lvalue
 Initializing the variable - declare a starting value, variables must be declared before used in
program
 num yourSalary = 14.55 / num yourSalary
 string yourName = “Janita” / string yourName
 Garbage – a variable’s unknown value, till it is given a value (input yourSalary)
 Named constant- Uppercase with underscores
 Can be assigned a value only once
 Assign a useful name to a value that will never be changed during a program’s execution,
or change once to change all instances
 Magic number
 Unnamed constant
 Use taxAmount = price * SALES_TAX_AMOUNT instead of taxAmount = price * .06 (magic
number)


Performing arithmetic operations
 Standard arithmetic operators:
+ (plus sign)- addition * (asterisk)- multiplication = (equal)- assignment
− (minus sign)- / (slash)- division
subtraction


 Rules of precedence (Order of operations)
Parenthesis
 Dictate the order in which operations in the same statement are Multiplication and
carried out Division
Addition and
 All the arithmetic operators have left-to-right associativity
subtraction
 Dividing an integer by another integer is a special case
 Dividing two integers results in an integer, and any fractional part of the result is lost
 The decimal portion of the result is cut off, or truncated
 A remainder operator (modulo operator/ modulus operator) contains remainder of a
division operation
 24 Mod 10 is 4, Because when 24 is divided by 10, 4 is the remainder


The advantages of modularization
 Modules -Subunit of programming problem (subroutines, procedures, functions, or methods)
 Call a module is to use its name to invoke the module, causing it to execute
 Modularization -Breaking down a large program into modules (functional
decomposition)
 Abstraction
 Paying attention to important properties while ignoring nonessential details
 One broad statement corresponds to dozens of machine instructions
 Multiple programmers can work on one problem
$3.89
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
tanjanel1303 Rosebank College (Pretoria)
Follow You need to be logged in order to follow users or courses
Sold
10
Member since
1 year
Number of followers
2
Documents
47
Last sold
2 months ago

5.0

2 reviews

5
2
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions