Docsity

NEWESTWGU C173 – SCRIPTING AND PROGRAMMING – FOUNDATIONS EXAM | COMPLETE CERTIFICATION E, Exams of Information Technology

Toggle sidebar
bg1
NEWEST WGU C173 – SCRIPTING AND
PROGRAMMING – FOUNDATIONS EXAM | COMPLETE
CERTIFICATION EXAM WITH CORRECT ANSWERS
AND RATIONALES |GUARANTEED CERTIFICATION
EXCELLENCE
1. Which statement best describes an algorithm?
A. A programming language used to write applications
B. A finite sequence of steps for solving a problem
C. A computer component that stores instructions
D. A collection of unrelated commands
Correct answer: B
Rationale: An algorithm is a finite, ordered set of
instructions designed to solve a problem or perform a task.
2. Which programming construct allows a program to
execute different instructions depending on whether a
condition is true or false?
A. Sequence
B. Iteration
C. Selection
D. Declaration
Correct answer: C
Rationale: Selection uses conditional statements such as
if/else to determine which instructions execute.
3. A programmer needs to store the number of students
enrolled in a course. Which data type is most appropriate?
A. Boolean
B. Integer
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24

Partial preview of the text

Download NEWESTWGU C173 – SCRIPTING AND PROGRAMMING – FOUNDATIONS EXAM | COMPLETE CERTIFICATION E and more Exams Information Technology in PDF only on Docsity!

NEWEST WGU C173 – SCRIPTING AND

PROGRAMMING – FOUNDATIONS EXAM | COMPLETE

CERTIFICATION EXAM WITH CORRECT ANSWERS

AND RATIONALES |GUARANTEED CERTIFICATION

EXCELLENCE

  1. Which statement best describes an algorithm? A. A programming language used to write applications B. A finite sequence of steps for solving a problem C. A computer component that stores instructions D. A collection of unrelated commands Correct answer: B Rationale: An algorithm is a finite, ordered set of instructions designed to solve a problem or perform a task.
  2. Which programming construct allows a program to execute different instructions depending on whether a condition is true or false? A. Sequence B. Iteration C. Selection D. Declaration Correct answer: C Rationale: Selection uses conditional statements such as if/else to determine which instructions execute.
  3. A programmer needs to store the number of students enrolled in a course. Which data type is most appropriate? A. Boolean B. Integer

C. String D. Character Correct answer: B Rationale: An integer stores whole-number values, making it appropriate for counting students.

  1. What is the primary purpose of a variable in a program? A. To permanently store program instructions B. To represent a named memory location whose value can be used or changed C. To prevent the program from executing D. To convert source code into machine code Correct answer: B Rationale: Variables provide named storage locations for data that a program can access and manipulate.
  2. Which value is an example of a Boolean literal? A. "False" B. 0. C. TRUE D. "Yes" Correct answer: C Rationale: Boolean values represent logical states, typically true and false. The quoted value "False" is a string.
  3. What is the result of the expression 8 + 3 * 2 when standard operator precedence is applied? A. 22 B. 14 C. 19 D. 16

Correct answer: B Rationale: Comments document code and explain its purpose. They are generally ignored by the program during execution.

  1. Which of the following best describes source code? A. Instructions written in a programming language B. Data stored only in a database C. A computer's physical memory D. The output displayed after program execution Correct answer: A Rationale: Source code consists of human-readable instructions written using the syntax of a programming language.
  2. What is the main purpose of a compiler? A. To translate source code into another form, such as machine code B. To create variables automatically C. To repair damaged computer hardware D. To store user passwords Correct answer: A Rationale: A compiler translates source code into machine code or another target representation so that it can be executed.
  3. Which programming error occurs when a statement violates the grammar rules of a programming language? A. Logic error B. Syntax error C. Hardware error D. Runtime result

Correct answer: B Rationale: Syntax errors occur when code does not follow the language's required structure.

  1. A program runs without crashing but calculates a customer's discount incorrectly. What type of error is most likely present? A. Syntax error B. Compilation error C. Logic error D. Hardware failure Correct answer: C Rationale: Logic errors occur when a program executes but produces incorrect results because its instructions or reasoning are flawed.
  2. What is a runtime error? A. An error that occurs while the program is executing B. An error caused only by incorrect indentation C. An error that always prevents source code from being saved D. An error that occurs before any code is written Correct answer: A Rationale: Runtime errors happen during execution, often because of invalid operations such as division by zero.
  3. Which activity is most directly associated with debugging? A. Designing a computer network B. Finding and correcting errors in a program C. Installing an operating system D. Writing a user manual
  1. Which flowchart symbol commonly represents the start or end of a process? A. Diamond B. Oval C. Rectangle D. Parallelogram Correct answer: B Rationale: An oval or terminator symbol indicates the beginning or ending point of a flowchart.
  2. A program asks a user to enter their age. Which operation is being performed? A. Output B. Input C. Iteration D. Compilation Correct answer: B Rationale: Input occurs when a program receives data from a user or another source.
  3. Which construct repeatedly executes a block of instructions while a condition remains true? A. Selection B. Iteration C. Declaration D. Assignment Correct answer: B Rationale: Iteration is repetition, commonly implemented using while, for, or do-while loops.
  4. Consider the pseudocode:

x = 5 x = x + 3 x = x * 2 What is the final value of x? A. 10 B. 13 C. 16 D. 21 Correct answer: C Rationale: First, x becomes 8. Multiplying 8 by 2 produces

  1. What is the result of 17 MOD 5? A. 2 B. 3 C. 5 D. 3. Correct answer: A Rationale: The modulo operation returns the remainder after division. Seventeen divided by five leaves a remainder of two.

  2. Which operator is commonly used for integer division in languages that distinguish it from ordinary division? A. + B. // C. == D. &&

  1. A program grants access only when a user enters the correct password and provides a valid authentication code. Which logical operator is most appropriate? A. OR B. AND C. NOT D. MOD Correct answer: B Rationale: Both conditions must be satisfied, so AND is appropriate.
  2. Which expression correctly checks whether a number is between 10 and 20, inclusive? A. number >= 10 OR number <= 20 B. number > 10 AND number < 20 C. number >= 10 AND number <= 20 D. number == 10 AND number == 20 Correct answer: C Rationale: The expression requires the number to be at least 10 and no greater than 20.
  3. What is the primary purpose of an if/else statement? A. To repeat a statement a fixed number of times B. To select between alternative execution paths C. To declare a data type D. To terminate the operating system Correct answer: B Rationale: An if/else statement evaluates a condition and chooses which block of code to execute.
  4. Consider the pseudocode:

score = 72 IF score >= 60 DISPLAY "Pass" ELSE DISPLAY "Fail" What is displayed? A. Fail B. Pass C. 60 D. Nothing Correct answer: B Rationale: Since 72 is greater than or equal to 60, the condition is true and "Pass" is displayed.

  1. Which structure is best suited to selecting one option from several possible values of a single expression? A. Switch or case statement B. While loop C. Variable declaration D. Function return statement Correct answer: A Rationale: A switch or case structure provides multiple branches based on the value of an expression.
  2. What is a nested conditional? A. A conditional statement placed inside another conditional statement B. A conditional statement that has no Boolean expression

C. A do-while loop cannot contain conditional logic D. A while loop cannot execute more than once Correct answer: B Rationale: A do-while loop evaluates its condition after the body, guaranteeing at least one execution.

  1. Which loop is generally most appropriate when the number of repetitions is known in advance? A. For loop B. Infinite loop C. Recursive call D. Conditional branch Correct answer: A Rationale: A for loop is commonly used when a program can determine the number of iterations before the loop begins.
  2. Consider the pseudocode: counter = 1 WHILE counter <= 4 DISPLAY counter counter = counter + 1 How many times does the loop execute? A. 3 B. 4 C. 5 D. 1 Correct answer: B Rationale: The counter takes the values 1, 2, 3, and 4 before becoming 5 and terminating the loop.
  1. What is an infinite loop? A. A loop that executes exactly once B. A loop that cannot reach its termination condition C. A loop that always contains an array D. A loop that executes only when a program is compiled Correct answer: B Rationale: An infinite loop continues indefinitely because its termination condition is never reached or never becomes false.
  2. A loop should process every number from 1 through 10. Which condition correctly includes 10? A. counter < 10 B. counter <= 10 C. counter > 10 D. counter == 10 Correct answer: B Rationale: The less-than-or-equal operator allows the loop to execute when the counter is exactly 10.
  3. What is the purpose of a loop counter? A. To store the program's source code B. To track the number of iterations or current position in a repetition C. To prevent all conditional statements D. To convert strings into integers Correct answer: B Rationale: A loop counter tracks progress through repeated execution and is often used to control termination.
  4. What is an array?

A. Attempting to access an array position that does not exist B. Attempting to add two integers C. Declaring a variable without a comment D. Printing an array element successfully Correct answer: A Rationale: An out-of-bounds error occurs when a program accesses an index outside the array's valid range.

  1. A programmer has an array containing 12 elements indexed from 0. What is the highest valid index? A. 10 B. 11 C. 12 D. 13 Correct answer: B Rationale: A zero-indexed array with 12 elements has indices 0 through 11.
  2. Which operation adds an element to the end of a dynamic array or list in many programming languages? A. Append B. Compare C. Compile D. Declare Correct answer: A Rationale: An append operation adds a new element to the end of a list or dynamic array.
  3. What is a string? A. A sequence of characters B. A whole-number value

C. A Boolean operator D. A type of loop Correct answer: A Rationale: Strings represent text as sequences of characters, including letters, digits, spaces, and symbols.

  1. Which value is a string literal? A. 42 B. false C. "Programming" D. 3. Correct answer: C Rationale: Text enclosed in quotation marks is commonly represented as a string literal.
  2. What is the result of concatenating "Data" and "Base"? A. Data Base B. DataBase C. BaseData D. Data + Base Correct answer: B Rationale: String concatenation joins two strings. Without an explicitly included space, the result is "DataBase".
  3. What is the purpose of a string-length function? A. To convert a string into a Boolean B. To determine the number of characters in a string C. To sort an array numerically D. To remove all variables from memory Correct answer: B Rationale: A length function returns the number of

C. 24

D. 46

Correct answer: B Rationale: The function receives 4 and 6, adds them, and returns 10.

  1. What is the purpose of a return statement? A. To send a value back to the calling code and end the function's execution B. To repeat the function indefinitely C. To declare a global variable D. To display every variable in memory Correct answer: A Rationale: A return statement provides a function's result to the code that called it and typically ends that function execution.
  2. What is a local variable? A. A variable accessible from every program B. A variable declared within a limited scope, such as a function C. A variable permanently stored in a database D. A variable that cannot hold a value Correct answer: B Rationale: Local variables are accessible only within their defined scope, such as the function or block where they are declared.
  3. What is a global variable? A. A variable whose scope allows access from multiple parts of a program

B. A variable that exists only inside a loop C. A variable that stores only whole numbers D. A variable that cannot be modified Correct answer: A Rationale: A global variable is declared in a scope that allows it to be accessed by multiple program components, subject to language rules.

  1. Why should programmers avoid excessive use of global variables? A. They make every program compile faster B. They can create unintended dependencies and make code harder to maintain C. They automatically prevent runtime errors D. They eliminate the need for functions Correct answer: B Rationale: Excessive global state makes program behavior harder to trace, test, and maintain because many components may modify shared data.
  2. What is a function call? A. A request to execute a function B. A declaration of an array C. A comparison between two strings D. A comment describing program logic Correct answer: A Rationale: A function call transfers control to a function so its instructions can execute.
  3. What is recursion?