Programming Fundamentals Study Guide
Quiz
1. Explain the di erence between a parameter and an argument in a function call.
2. Describe the purpose of the void data type in programming.
3. What is the di erence between global scope and local scope for a variable?
4. Why is programming style important? Provide two examples of good programming
style mentioned in the source.
5. What is a standard library in programming and why are they useful?
6. Explain the basic structure of an if-then-else control structure.
7. What is a code block and why are they used in programming?
8. List three common relational operators and their meanings.
9. What is the primary di erence between a test before loop (like while or for) and a
test after loop (like do while or repeat until)?
10. How is the concept of a "flag" used in comA parameter is the variable identifier
defined in the function's signature, acting as a placeholder for input data. An
argument is the actual value passed to the function when it is called, which is
assigned to the corresponding parameter.
12. The void data type is used to indicate the lack of a return value
from a function or that nothing is being passed in as a parameter. It
signifies that the function completes its task but does not provide a
result back to its caller.
13. Global scope variables are defined outside of any function and
are accessible from anywhere within the program. Local scope
variables are defined inside a function and are only accessible within
that specific function.
14. Programming style helps programmers read and understand
source code, reducing errors and improving maintainability. Two
examples are declaring each variable on its own line and using
meaningful identifier names.
15. A standard library is a collection of pre-written, tested, and
commonly used functions and code modules that programmers can
readily use in their programs. They save development time and e ort by
providing reliable solutions for common tasks.
16. The if-then-else structure evaluates a Boolean expression. If the
expression is true, the code block after the if (or then) is executed. If it is
false, the code block after the else is executed.
17. A code block is a group of one or more statements or declarations
treated as a single unit. They are fundamental to structured
programming and are used with control structures to group the code
that will be executed conditionally or repeatedly.
18. Three common relational operators are: < (less than), > (greater than), and == (equality or
equal to).
19. A test before loop checks the loop condition before executing the code block, meaning the
block might not run at all if the condition is initially false. A test after loop executes the code
block at least once before checking the condition for the first time.
20. A flag in computer programming is a variable or constant used to store information that
signals the state or outcome of an operation. This flag is then checked, often in a test
expression within a control structure, to make decisions and control program flow.
22. convert_to_textConvert to source
23. puter programming?
What is the di erence between parameters and arguments in a function?
A parameter is a special type of variable listed in a function's definition. It acts as a placeholder for
the data that the function will receive. Arguments are the actual values that are passed to the
function when it is called. The value of an argument is assigned to the corresponding parameter
within the function. While the terms are often used interchangeably, a parameter refers to the
variable identifier (e.g., fahrenheit), and an argument refers to the variable value (e.g., 100).
What is the "void" data type used for?
The void data type is used to indicate the absence of a data type. It has no values and no
operations. It is typically used in function definitions or prototypes to signify that the function does
not return a value to its caller, or that it does not take any parameters.
How does scope a ect where a variable can be used in a program?
Scope defines the region within a program where an identifier name, such as a variable, is
recognised. Global scope means a variable is defined outside of any function and is accessible to
all functions in the program. Local scope means a variable is defined inside a function and is only
accessible from the point of definition to the end of that function. Parameters passed to a function
also establish local variables within that function.
Why is programming style important?
Programming style is a set of rules or guidelines for writing source code. Following a consistent
style makes code more readable and understandable for other programmers (and the original
programmer later on). This helps to avoid errors and makes debugging easier. Examples of
programming style include declaring one variable per line, using consistent indentation, and
choosing meaningful identifier names.
What are standard libraries in programming?
Standard libraries are collections of pre-written functions and code that are commonly used in
programming. These functions have been written, tested, and reviewed by experienced
programmers, providing reliable tools for various tasks (like mathematical operations). Using
standard libraries saves programmers time and e ort as they don't have to write these common
functionalities from scratch.
How do conditional control structures like "if then else" work?
Conditional control structures, such as the if then else statement, allow a program to make
decisions based on whether a test expression is true or false. If the expression evaluates to true,
one block of code is executed. If it evaluates to false, another block (the "else" part) may be
executed. The test expression is usually a Boolean expression involving relational or logical
operators. Languages may have variations in syntax, but the core concept of executing di erent
code paths based on a condition remains the same. Nesting conditional structures involves placing
one if then else statement inside another to handle more complex logic.
What is the purpose of iteration (looping) control structures?
Iteration control structures, or loops, are used to repeat a block of code multiple times. They are
controlled by a Boolean expression, which determines how often the loop will execute. Common
types of loops include while loops (test before), do while or repeat until loops (test after), and for
loops (typically used for counting). Key attributes of a properly working loop include initializing a
flag (a variable that controls the loop), a test expression, the action(s) to be repeated, and updating
the flag to ensure the loop eventually terminates. Failure to update the flag or an incorrect test
expression can lead to an infinite loop.
What are branching statements used for?
Branching statements allow the flow of execution in a program to jump to a di erent part of the
code, deviating from the sequential order. Common branching statements include break (used to
exit a loop or switch statement), continue (used to skip the rest of the current iteration of a loop and
move to the next), return (used to exit a function and optionally return a value), and exit (a
predefined function to prematurely stop the entire program). The goto statement, while a branching
statement, is generally discouraged in structured programming.