16.7k views
2 votes
A program is used to print name tags for guests at an event. Unfortunately for each guest it prints the last name before the first name when the opposite is desired. The procedure for printing the name tags uses the variables FN for the first name and LN for last name. Which of the following code segments, inserted in the correct place in the procedure will cause the program to print the name tags in the desired way?

1) Swap the values of FN and LN before printing
2) Change the variable names FN and LN to First and Last
3) Add a new variable TN and assign it the value of FN before printing
4) Remove the variable LN and use FN as the last name

User Gvenzl
by
8.3k points

1 Answer

6 votes

Final answer:

The correct code segment to use in order to print the name tags in the desired way is option 1) Swap the values of FN and LN before printing.

Step-by-step explanation:

The correct code segment to use in order to print the name tags in the desired way is option 1) Swap the values of FN and LN before printing.

By swapping the values of FN (first name) and LN (last name) before printing, the program will print the last name before the first name, as desired.

For example, if the original values of FN and LN were 'John' and 'Doe' respectively, using the swap method would result in 'Doe John' being printed on the name tag.

User Nowayz
by
7.8k points