Question 330
A RHEL 10 shell script executes the following code. What value is printed? #!/bin/bash total=0 for n in {6..10}; do total=$((total+n)); done printf "%d" "$total"
Explanation
Correct Answer
Bash expands {6..10} into 5 loop values, inclusive, then arithmetic expansion accumulates their sum: (6+10)×5÷2 = 40. printf formats the resulting integer as 40 without a newline.
Incorrect Answers
Value 34 is inconsistent with the inclusive Bash brace range from 6 through 10. The loop adds exactly 5 values and the arithmetic series yields (6+10)×5÷2 = 40; it does not skip an endpoint or count entries only.
Value 50 is inconsistent with the inclusive Bash brace range from 6 through 10. The loop adds exactly 5 values and the arithmetic series yields (6+10)×5÷2 = 40; it does not skip an endpoint or count entries only.
Value 5 is inconsistent with the inclusive Bash brace range from 6 through 10. The loop adds exactly 5 values and the arithmetic series yields (6+10)×5÷2 = 40; it does not skip an endpoint or count entries only.






Red Hat Certified System Administrator (RHCSA) (EX200) Practice Tests